>>T-SQL has some ideas for running totals (like Jeff Moden quirky update), but it's not official solution and not supported. So, for these kind of problems T-SQL may not be a good choice.
>>
>>Unless I misunderstood the problem.
>>
>>Perhaps you can post your table structure, what exactly do you want to get in SQL forum, then it will be easier to provide a solution.
>
>Maybe this will get me the number of premiums paid:
>
>
SELECT NumberMonthsToAdd = SUM(
> CASE [PremiumMode]
> WHEN 'Monthly' THEN NumberOfPremiums * 1
> WHEN 'Quarterly' THEN NumberOfPremiums * 3
> WHEN 'Semi-Annually' THEN NumberOfPremiums * 6
> WHEN 'Annually' THEN NumberOfPremiums * 12
> ELSE 0
> END )
> FROM [dbo].[ReceiptDetails]
>
>
>This way I don't need to loop through to get the result. What do you think?
Looks good to me.
If it's not broken, fix it until it is.
My Blog