Is this statement is possible? here is the code:
select sum(nPassengers) Planned, Actual, (sum(Planned) - Actual) Variance
from (
select iDeptCode, sum(nPassengers) Planned from tbl_BusRequest
where iReqTime = '1' and iDeptCode = '1' and cReqType = 'I'
group by iDeptCode
and
(Actual = (Select nPassengers from tbl_Riders_NonRiders where dtDate = '11/05/06'
AND cReqType = 'i' and iTimeCode = '1' and iDeptCode = '1' )
and im getting this error:
Server: Msg 156, Level 15, State 1, Line 6
Incorrect syntax near the keyword 'and'.
Thankssee your previous post for the possible solution|||
Quote:
Originally Posted by intscript
Hello everyone!
Is this statement is possible? here is the code:
select sum(nPassengers) Planned, Actual, (sum(Planned) - Actual) Variance
from (
select iDeptCode, sum(nPassengers) Planned from tbl_BusRequest
where iReqTime = '1' and iDeptCode = '1' and cReqType = 'I'
group by iDeptCode
and
(Actual = (Select nPassengers from tbl_Riders_NonRiders where dtDate = '11/05/06'
AND cReqType = 'i' and iTimeCode = '1' and iDeptCode = '1' )
and im getting this error:
Server: Msg 156, Level 15, State 1, Line 6
Incorrect syntax near the keyword 'and'.
Thanks
You may want to put the results of the second 1/2 of your query in a temp table, then select from there.
A bit easier to read, if nothing else
No comments:
Post a Comment