SQLTeam.com | Weblogs | Forums

Joining 2 grouped queries


#1

Hi folks,

I can't seem to figure this one out although I just know that it must be so simple... I need to do a JOIN on 2 GROUP queries.

Select TransactionID, Round(Sum(Debt),2) as SumDebt1 From Transactions Group by TransactionID as T1 JOIN
(Select TransactionID, Round(Sum(Debt),2) as SumDebt2 From TransactionDetails Group by TransactionID) as T2
On T1.TransactionID = T2.TransactionID

Can anyone nudge me in the right direction? Thanks!


#2
SELECT *
FROM
(
    Select TransactionID, Round(Sum(Debt),2) as SumDebt1 From Transactions Group by TransactionID 
)   as T1 
JOIN 
(
   Select TransactionID, Round(Sum(Debt),2) as SumDebt2 From TransactionDetails Group by TransactionID
) as T2
On T1.TransactionID = T2.TransactionID

#3

I hate it when I'm stupid... Thanks for taking the time to help out a poor lost soul. Cheers!