customerID register date inactive date Incentives flag 1 1/1/2014 1/6/2015 0 2 1//1/2013 NULL 1 3 11/1/2013 NULL 0 4 11/1/2006 1/6/2013 1 5 12/4/2007 12/1/2013 1 6 9/2/2010 NULL 1
4 12/1/2013 NULL 0
1 03/1/2015 NULL 0
I have a table like above, I need to develop T-SQl to generate the following fields
a)year
b)Quarter (calendar year-Quarter)
c)incentives flag
d) inactive customers count previous quarter
e) Inactive customers count this quarter
f) Inactive customers next quarter
g) active after the end of the next quarter