Here is my select statement, I'm using sql server 2005. When I run it, I get Incorrect syntax near ')' on line 17 - (the last line). I new to SQL and trying to create a report in reporting services.
I'm used to using MS Access. Basically, like in Access, when you can choose a query to the be record source for another query. I'm trying to do something like that.
Select [Part Number], [Invt GLG], Sum(PYUsage), Sum(CYUsage)
from
(SELECT [Part Number], [Invt GLG], Qty, [Trans Dt],
'PYUsage'=
case
When Year([Trans Dt]) = '2007' Then [Qty]
Else '0'
End,
'CYUsage'=
case
When Year([Trans Dt]) = '2008' Then [Qty]
Else '0'
End
FROM [tblEMG_LIVE_INVTRAIL-2]
where [Trans Dt] >= N'1/1/2007' and [Qty] < '0')
I'm used to using MS Access. Basically, like in Access, when you can choose a query to the be record source for another query. I'm trying to do something like that.
Select [Part Number], [Invt GLG], Sum(PYUsage), Sum(CYUsage)
from
(SELECT [Part Number], [Invt GLG], Qty, [Trans Dt],
'PYUsage'=
case
When Year([Trans Dt]) = '2007' Then [Qty]
Else '0'
End,
'CYUsage'=
case
When Year([Trans Dt]) = '2008' Then [Qty]
Else '0'
End
FROM [tblEMG_LIVE_INVTRAIL-2]
where [Trans Dt] >= N'1/1/2007' and [Qty] < '0')