I have got a database that stores when customers activated and unsubscribed from the service. What I wish to do is see who unsubscribed every month, after which see the number of of individuals people had unsubscribed within thirty days of signing up. I've two fields,
DateUnsub_ that both return a
smalldatetime. Wouldso would I have the ability to find these folks using
DateUnsub? I understand I must perform some kind of calculation, and that i could do that easily basically wasn't using SQL - any suggestions?
SELECT * FROM UserTable WHERE DATEDIFF(day, DateJoined, DateUnSub) <= 30
What DBMS are you currently using? For MySQL:
select * from table where DATEDIFF(DateUnsub_, DateJoined_) <= 30
For getting the amount of customers who unsubscribed every month, you can
GROUP BY DATEPART(year, DateUnsub_), DATEPART(month, DateUnsub_) or rather limit on individuals dateparts to obtain the listing of customers.