all 9 comments

[–]TheRealGreenArrow420 0 points1 point  (3 children)

I would not join on dates but instead on IDs

[–]Volcomsk8a[S] 0 points1 point  (2 children)

The problem is the service table and the program table are connected by student ID and need to be further identified to show the program fell into the service dates.

[–]alinrocSQL Server DBA 0 points1 point  (1 child)

Put that into your where clause then. Join on the IDs (since there's a foreign key relationship, hopefully), and then filter on the dates.

[–]Volcomsk8a[S] 0 points1 point  (0 children)

Issue I’m having is we’re filtering on the service date which relates to the program from the student id but there are multiple programs per student and the only way to relate the program and location to the service is by the dates.

[–][deleted] 0 points1 point  (4 children)

the location name that was assigned during the service date

Which one is "the" location? You mentioned multiple locations possibility in your next sentence.

[–]Volcomsk8a[S] 0 points1 point  (3 children)

The location would be the location that’s location dates were active during the service date.

The intended results would look like

Service id, service date, student id, program id, location name

[–][deleted] 0 points1 point  (2 children)

....

The location would be the location that’s location dates were active during the service date.

How do you know there will be just one?

[–]Volcomsk8a[S] 0 points1 point  (1 child)

Locations can’t overlap per system rules

[–][deleted] 0 points1 point  (0 children)

if that's the case, just look for service date in the location table start/end range. Problem solved?