Link to home
Start Free TrialLog in
Avatar of wilcosw
wilcoswFlag for South Africa

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 ?
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of wilcosw

ASKER

Great,
Thanks for the quick response !