Get consolidated results with following tables

Posted by Ted on Stack Overflow See other posts from Stack Overflow or by Ted
Published on 2010-05-20T06:14:47Z Indexed on 2010/05/20 6:20 UTC
Read the original article Hit count: 168

Filed under:
|
|

I have a scenario. Here's my table structure is:

ID          LoginDate             RemovalDate
----------------------------------------
1           2009/08/01            NULL
2           2009/09/12            2010/01/02
3           2009/08/31            2009/10/29
4           2010/02/17            NULL
5           2009/10/18            2009/11/22

I want a consolidated results of how many ID's were not removed in a particular month. So the result set should be

Date         NotRemoved_ID
--------------------------
2009/08      2
2009/09      3
2009/10      3 [One ID got removed in 2009/10]
2010/02      2 [Two got removed in 2009/11 and 2010/01]

Please help.

© Stack Overflow or respective owner

Related posts about sql

Related posts about query