- Sep 23, 2003
- 11,448
- 262
- 126
Hey guys,
I hope I'm an established member around here at this point, so I'm just going to straight up ask the question . I'm expecting this to be cake for any real SQL dev.
To break it down to the simplest data points, basically what I want to figure out are 2 things with one query statement, although it is not required if it makes sense to do 2.
Essentially I have employee ID's with dates with some additional data that makes each date unique to each employee, simple set that will outline my scenario below:
I have a specified date range of 1/1/15 to 1/2/15 so I want to pull all the employee ID's, dates & values for matching date ranges - but one special caveat. Notice how Employee ID 2 does not have an entry for 1/2/15? I want all of their rows excluded because they don't have data for my ending date of 1/2/15. So in this case, I should only receive the 2 rows back for Employee ID 1.
Hope that makes sense... the only solutions I could think of involved filtering data some how after it was retrieved... can you do this in a single query? I am a SQL novice and only do real basic data retrieval so this could be trivial.
I hope I'm an established member around here at this point, so I'm just going to straight up ask the question . I'm expecting this to be cake for any real SQL dev.
To break it down to the simplest data points, basically what I want to figure out are 2 things with one query statement, although it is not required if it makes sense to do 2.
Essentially I have employee ID's with dates with some additional data that makes each date unique to each employee, simple set that will outline my scenario below:
Code:
EMPID DATE VAL
1 1/1/15 1
1 1/2/15 2
2 1/1/15 1
I have a specified date range of 1/1/15 to 1/2/15 so I want to pull all the employee ID's, dates & values for matching date ranges - but one special caveat. Notice how Employee ID 2 does not have an entry for 1/2/15? I want all of their rows excluded because they don't have data for my ending date of 1/2/15. So in this case, I should only receive the 2 rows back for Employee ID 1.
Hope that makes sense... the only solutions I could think of involved filtering data some how after it was retrieved... can you do this in a single query? I am a SQL novice and only do real basic data retrieval so this could be trivial.