December 17, 2006 at 2:26 am
I wish to get in one single query Roll up Total of Amount from the folowing structures
Table MGroup
Fields GroupCode, GroupName, Amount
Table mLedger
Fields LedgerCode, LedgerName, GroupCode, Amount
December 17, 2006 at 8:20 am
something like this probably....cannot test...
select G.GroupCode, sum(G.amount)+ max(L.amount) as totalAmount from MGroup G inner join (select GroupCode, sum(amount) as amount from MLedger group by Groupcode)L on G.GroupCode = L.GroupCode group by G.GroupCode
**ASCII stupid question, get a stupid ANSI !!!**
December 20, 2006 at 12:45 pm
If you change the last line to "group by G.GroupCode WITH ROLLUP", you'll get an extra row with the grand total for Amount (and a NULL for GroupCode). Is that what you're looking for?
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply