eo
MIS
- Apr 3, 2003
- 809
Hi,
SQL server 2005
I have a table with a value, a date and a claim number (amonst many other fields). I want to create a new calculated value (field) that shows the original value, but only until a top limit has been reached and for this to reset with every claim number. This could easily be done by grouping by the claim number and the date and using a case statement to do the calculatioon, but I cannot re-granularise my records. I was therefore hoping to use some cursor function to do this.
Assuming the upper value is 520, I will explain by example (the example shows two claim numbers 23 and 24 both over the 520 limit, and claim number 25 well within the 520 limit):
Is this possible?
EO
Hertfordshire, England
SQL server 2005
I have a table with a value, a date and a claim number (amonst many other fields). I want to create a new calculated value (field) that shows the original value, but only until a top limit has been reached and for this to reset with every claim number. This could easily be done by grouping by the claim number and the date and using a case statement to do the calculatioon, but I cannot re-granularise my records. I was therefore hoping to use some cursor function to do this.
Assuming the upper value is 520, I will explain by example (the example shows two claim numbers 23 and 24 both over the 520 limit, and claim number 25 well within the 520 limit):
Code:
ClaimNo Date Value New520TopLimitValue
23 01/01/2006 100 100
23 01/06/2007 100 100
23 25/07/2007 100 100
23 01/01/2008 100 100
23 13/01/2008 100 100
23 04/02/2008 100 20
23 13/11/2008 100 0
24 14/08/2004 300 300
24 18/08/2004 200 200
24 16/07/2008 348 20
24 18/11/2008 600 0
24 19/11/2008 700 0
25 01/02/2008 16 16
25 02/02/2008 400 400
Is this possible?
EO
Hertfordshire, England