wilcosw
asked on
Passing value from nested select sub query to upper select
Hi,
I need to get a value from a subquery, to the topmost level.
For instance select sum of sales for a week period, plus select sum of sales for only a day.
Something like the following:
Select sum(TableA.nValue), sum(TableC.nValue) from TableA --this is where the problem is !!!
join TableB on TableA.PK = TableB.PK
where TableA.PK in
( Select PK from TableA TableC
join TableB TableD on TableC.PK = TableD.PK
where TableC.date => '2008-10-13' and TableC.date < '2008-10-20'
)
and TableA.Date <= '2008-10-13' and TableA.date < '2008-10-14'
How can I do this without needing all sorts of vars etc ? Can I reference it directly ?
I need to get a value from a subquery, to the topmost level.
For instance select sum of sales for a week period, plus select sum of sales for only a day.
Something like the following:
Select sum(TableA.nValue), sum(TableC.nValue) from TableA --this is where the problem is !!!
join TableB on TableA.PK = TableB.PK
where TableA.PK in
( Select PK from TableA TableC
join TableB TableD on TableC.PK = TableD.PK
where TableC.date => '2008-10-13' and TableC.date < '2008-10-20'
)
and TableA.Date <= '2008-10-13' and TableA.date < '2008-10-14'
How can I do this without needing all sorts of vars etc ? Can I reference it directly ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the quick response !