Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Les.61
Starting Member
49 Posts |
Posted - 2009-12-15 : 21:11:52
|
I an trying to report on ALL accounts and then total of transactions from a particular date. If there are no transactions since that date it should return o.oo or NULLMy code isuse reportinggoselect a.balance, sum (transamount)AS TotalToDatefrom dbo.AcctransCrDr as Aright outer join dbo.TranAccount As ton a.id = t.id--where transprocessdate >= '2009-12-01 00:00:00.000'group by A.Id, a.balanceORDER BY TotalToDateIt works fine and returns 7,300 lines however when I uncomment the 'where' line it only returns any accounts with transactions since 1 Dec 2009. I thought using a right outer join would list all from the right hand table (ie TranAccount) and then the sum of balances from the AcctransCrDr if appliable otherwise NULL.Where am I going wrong?  |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-12-16 : 01:54:20
|
| Instead of where use andMadhivananFailing to plan is Planning to fail |
 |
|
|
Les.61
Starting Member
49 Posts |
Posted - 2009-12-16 : 18:39:10
|
| Still only get the accounts that have had transactions and not all the accounts.Les |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-12-17 : 01:56:58
|
| Try thisuse reportinggoselect a.balance, sum (transamount)AS TotalToDatefrom dbo.TranAccount As tleft outer join dbo.AcctransCrDr as Aon a.id = t.idand transprocessdate >= '2009-12-01 00:00:00.000'group by A.Id, a.balanceORDER BY TotalToDateMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|