Help with SQL statement that compairs dates.
Good Morning!
It may be simple or it may be impossible. Situation:
A person gets flagged. they have a flag start date(DATE_REPT_SFPA1) and a flag end date (DATE_REMVD_SFPA1). There is 1 throgh 5. so max of 5 times someone can get flagged.
The data in the columns is MM/DD/YYYY 0.00
Goal:
To find the total # of people currently flagged.
So...
If person has DATE_REPT_SFPA1 and no DATE_REMVD_SFPA1 = flagged.
If person has DATE_REPT_SFPA1 and a DATE_REMVD_SFPA1 = not flagged.
I currently have.
SELECT COUNT (DATE_REPT_SFPA1) from bla.dbo.bla WHERE DATE_REPT_SFPA1 <> ' ' (because yes... its blank not NULL)
SELECT COUNT (DATE_REMVD_SFPA1 ) from bla.dbo.bla WHERE DATE_REMVD_SFPA1 <> ' '
it gives me 2 results 549 with start flag dates and 479 with end flag dates. So 70 people are currently flagged.
Now... How do combine and subtract those numbers?
The over all goal is to pull real time data (in visual studio) in a graph to show # of people each office has and how many of that office's people are currently flagged.
Sorry I'm new and have been doing alot of self teaching, and going to a course in 4 months.
Thank you!
|