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 |
|
kellog1
Starting Member
35 Posts |
Posted - 2010-08-16 : 16:44:36
|
| Guys,I am trying to calculate running totals and I am getting incorrect results. Below is my query...select PublicationId,ProjectPublicationId, ControlFundingAmount, (select sum(ControlFundingAmount) from DimProjectPublication pp1 where pp1.ProjectPublicationId = pp.ProjectPublicationId and pp1.PublicationId = pp.PublicationId)from DimProjectPublication ppwhere ProjectPublicationId IN (135750,135211)order by ProjectPublicationIdResult:PublicationId ProjectPublicationId ControlFundingAmount RT43 135211 200000.00 200000.0043 135750 150000.00 150000.00Desired Result:PublicationId ProjectPublicationId ControlFundingAmount RT43 135211 200000.00 200000.0043 135750 150000.00 350000.00 |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2010-08-16 : 19:31:38
|
| Without knowing what your tables actually look like, try thiswhere pp1.ProjectPublicationId = pp.ProjectPublicationIdand pp1.PublicationId >= pp.PublicationId)JimEveryday I learn something that somebody else already knew |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-08-17 : 11:17:54
|
| shouldnt it be?where pp1.ProjectPublicationId = pp.ProjectPublicationIdand pp1.PublicationId <= pp.PublicationId)------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|