I have a query
SELECT ROW_NUMBER() OVER (PARTITION BY [CLIENT NO] ORDER BY Business_Date ASC) AS AGE_IN_DAYS,*
FROM #TEMP
WHERE COLLATERAL_VALUE < 0 AND [CLIENT NO] = 'XXXXXX'
which gives Result set As:
GEA_IN_DAYS CLIENT NO MARKET_VALUE COLLATERAL_VALUE Business_Date PERSHING ID
1 xxxxx -3102.37 -332884.83 12/13/2016 2VX031579
2 xxxxx -4963.8 -334467.04 12/14/2016 2VX031579
3 xxxxx -17952.41 -345507.36 12/15/2016 2VX031579
4 xxxxx -428.28 -428.28 12/22/2016 2VX031579
I need to update the column AGE_IN_DAYS
as per the Business_date
.
if Business_date
is continuous I need to update AGE_IN_DAYS
by '1'.
in the above example I need to increment first 3 records by '1' and last one I need to count again starting from 1.
can any one please suggest me how can I do this?