Lead and Lag functions

Hi,

 

I have a script as follows which extracts info for a.FPR_SERV_NO by month. Some months have  no data for the FPR_SERV_NO. I want to flag those as removals, and if it is added back, I want to flag it as an addition. Also the first time it is added, I want to flag it as an addition. Please see attached for sample data, and the Output I want to get. Ive been trying to use Lead and Lag, but not getting it to work properly. Doesnt have to be these functions though, but anything that will work. Will appreciate any help..thanks! 

 

select a.FPR_SERV_NO,a.TIME_STAMP, a.FPR_RENTAL_CHARGE
from cis_prod.CST_FULL_PERIOD_RENTALS a
where a.FPR_SERV_NO in ('6231021', '6622997')

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file