July 14, 2010 at 12:20 pm
Hi All
I am not sure how to get a sum total of the balances of each distinct policy number. I know this is probably pretty easy I am just not sure how to do it.
Thanks
Craig
policy_numberBalance
800186 16247
800939 12138
800939 18581
800953 7679
800953 21969
800953 40929
800953 46132
800953 68129
800954 29678
800955 13075
801053 10809
801053 11431
801053 12584
801053 21610
801053 48862
801053 277046
July 14, 2010 at 12:24 pm
Pretty basic group by expression
select Policy_Number, sum(balance)
from table
group by Policy_Number
For better, quicker answers, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
July 16, 2010 at 12:39 am
You can also use the SUM and GROUP BY with arguments like ROLLUP or CUBE these will give a summary row of the policy. GROUPING SETS for multiple groupings of data.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply