Hello,
Relative SQL newbie here. I do a lot of work for my non-profit in reporting. I'm hitting the upper boundary of my limited sql skillset with this query:
Payroll office wants to find those individuals who have multiple records of work per day whose time overlaps:
To simplify, record of work has fields for Date, Department Code, Person ID, Start Time, End Time, plus other fields not important for this query
For example, given this table of data
DATE | DEPT| ID | Start | End
1/1/2017 | 1015 | 55 | 9:00AM | 10:00AM
1/1/2017 | 1015 | 55 | 10:00AM | 2:00PM
1/2/2017 | 1015 | 40 | 8:00AM | 9:00AM
1/2/2017 | 1040 | 40 | 8:30AM | 10:00AM
1/2/2017 | 1015 | 20 | 9:00AM | 12:00PM
I want the query to return:
1/2/2017 | 1015 | 40 | 8:00AM | 9:00AM
1/2/2017 | 1040 | 40 | 8:30AM | 10:00AM
These two records are on the same day, for the same person, but there is a time overlap.
I have no idea where to start. Help would be much appreciated
Note: In the database the data type for the start and end time fields is nvarchar. They are not connected with the date field.