Tuesday, February 21, 2012

Retrieve data using multiple select

Hi everyone

Is is possible to retrieve data using multiple select. Here is my SQL 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' )

Thanksi'm not sure your script will run as written. This is what I can come up with from your code:

select sum(nPassengers) Planned, Actual, (sum(nPassengers) - Actual) Variance from tbl_BusRequest
where iReqTime = '1' and iDeptCode = '1' and cReqType = 'I'

and
(Actual = (Select nPassengers from tbl_Riders_NonRiders where dtDate = '11/05/06'
AND cReqType = 'i' and iTimeCode = '1' and iDeptCode = '1' ))

No comments:

Post a Comment