SQLNewbiexaus
Technical User
I have these 4 queries but I am new to SQL and I can't figure out how to put them into 1 table. Can someone please help?
Select
count (P.Pass) PastLight
From
Transactions T (nolock)
Inner Join
Invoicing I (nolock) on T.InvoicingID = I.InvoicingID
Inner Join
Passes P (Nolock) on I.Pass = P.Pass
Where
T.DateTime > '20110130'
And
P.UseForPastTrips = '0'
And
Overall < '4'
Select
count (P.Pass) PastHeavy
From
Transactions T (nolock)
Inner Join
Invoicing I (nolock) on T.InvoicingID = I.InvoicingID
Inner Join
Passes P (Nolock) on I.Pass = P.Pass
Where
T.DateTime > '20110130'
And
P.UseForPastTrips = '0'
And
Overall > '3'
Select
count (P.Pass) FutureLight
From
Transactions T (nolock)
Inner Join
Invoicing I (nolock) on T.InvoicingID = I.InvoicingID
Inner Join
Passes P (Nolock) on I.Pass = P.Pass
Where
T.DateTime > '20110130'
And
P.UseForPastTrips = '1'
And
Overall < '4'
Select
count (P.Pass) FutureHeavy
From
Transactions T (nolock)
Inner Join
Invoice I (nolock) on T.Invoice = I.Invoice
Inner Join
pass P (Nolock) on I.Pass = P.Pass
Where
T.DateTime > '20110130'
And
P.past = '1'
And
Overall > '3'
Select
count (P.Pass) PastLight
From
Transactions T (nolock)
Inner Join
Invoicing I (nolock) on T.InvoicingID = I.InvoicingID
Inner Join
Passes P (Nolock) on I.Pass = P.Pass
Where
T.DateTime > '20110130'
And
P.UseForPastTrips = '0'
And
Overall < '4'
Select
count (P.Pass) PastHeavy
From
Transactions T (nolock)
Inner Join
Invoicing I (nolock) on T.InvoicingID = I.InvoicingID
Inner Join
Passes P (Nolock) on I.Pass = P.Pass
Where
T.DateTime > '20110130'
And
P.UseForPastTrips = '0'
And
Overall > '3'
Select
count (P.Pass) FutureLight
From
Transactions T (nolock)
Inner Join
Invoicing I (nolock) on T.InvoicingID = I.InvoicingID
Inner Join
Passes P (Nolock) on I.Pass = P.Pass
Where
T.DateTime > '20110130'
And
P.UseForPastTrips = '1'
And
Overall < '4'
Select
count (P.Pass) FutureHeavy
From
Transactions T (nolock)
Inner Join
Invoice I (nolock) on T.Invoice = I.Invoice
Inner Join
pass P (Nolock) on I.Pass = P.Pass
Where
T.DateTime > '20110130'
And
P.past = '1'
And
Overall > '3'