|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Help with modifying SUM
Table Structure
DCR ------ CustomerNumber CC PDC EnteredDate FeeGoal FeeSchedule PostedAmount I need a query which will do: SUM(PostedAmount + SUM(All PDC where EnteredDate in current month) + SUM(All CC where entered date in current month) + SUM(All PDC where EnteredDate not in current month) + SUM(All CC where entered date in current month)) * FeeSchedule for each company call that In-House for the above Sum Then I need to do a grand total on all In-House as one sum. I did something similar like this for another calculation but it didn't include the additions of PDC and CC. That query looked like this: Select Total = SUM(gt) FROM (Select Distinct CustomerName, CustomerNumber, FeeGoal AS FG, FeeSchedule, (cast(FeeGoal as numeric(30,10)) / FeeSchedule) * 100 AS gt from DCR WHERE branch='00002' group by CustomerName, CustomerNumber, FeeGoal, FeeSchedule ) as dTable so really what I want to change is (cast(FeeGoal as numeric(30,10)) / FeeSchedule) * 100 to add the PDC and CC sums and then * FeeSchedule instead of / like I have here |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Microsoft SQL Server > Help with modifying SUM |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|