SQL - Different sum levels in one select with where clause -


I have 2 tables are a basic amount that remains constant in the second table applied to the time against the original amount in the first table There is a list of partial amounts.

DB Tables: *** Memotable *** ID [Primary, Exclusive] Zodiac (General Zodiac) *** TranStable *** ID [Single in Memotable] Id ID number in transtable ID; Date applied (date apply)

I last week (apply> 2011-04-21), used to date Want to find a single selection, ID, amount used in the amount that was made?

The only rows that should be shown in the result are when an amount has been used from the previous week (apply> 2011-04-21).

I am stuck in trying to get the amount for the amount used to date, because it needs to be included in the amount the values ​​used when that apply & gt; 2011-04-21.

In this case it is possible to avoid sub-selection: <<< Code > SELECT ID, AmountUsedSinceLastWeek = SUM (in case when applying> 4/21/2011 'then the amount used END) amount from

Comments