Something like this should get you started...SELECT a.AccountID, a.AccountName, SUM(a.DebitAmount), SUM(a.CreditAmount)FROM ( SELECT debitid as AccountID, t2.[name] as AccountName, amount as DebitAmount, 0 as CreditAmount FROM transactiontable t1 JOIN account t2 ON t1.debitid = t2.[id] UNION ALL SELECT creditid as AccountID, t2.[name] as AccountName, 0 as DebitAmount, amount as CreditAmount FROM transactiontable t1 JOIN account t2 ON t1.debitid = t2.[id] ) aGROUP BY AccountID, AccountName
---------------------------EmeraldCityDomains.com