baitmaster
Well-known Member
- Joined
- Mar 12, 2009
- Messages
- 2,042
I’m working with SQL in Excel, and it’s working well. Now I want to add a new query that’s slightly more complex than the others and is outside my limited SQL comfort range.
I have 3 tables (worksheets):
RouteNum is the same in several tables. Location1 equates to Destination and Location2 equates to Origin
I want to find the whole record in table 1 where (DepTime less timeTaken) is the earliest possible but greater than a given time X
I can see I need to do some joins and probably a subquery but I’m unsure the best approach. Can anyone please write a single SQL query that will do this?
Thanks
I have 3 tables (worksheets):
- Table1 contains JourneyRef, RouteNum, DepTime, ArrTime
- Table 2 contains RouteNum, Origin & Destination
- Table 3 contains Location1, Location2 and timeTaken
RouteNum is the same in several tables. Location1 equates to Destination and Location2 equates to Origin
I want to find the whole record in table 1 where (DepTime less timeTaken) is the earliest possible but greater than a given time X
I can see I need to do some joins and probably a subquery but I’m unsure the best approach. Can anyone please write a single SQL query that will do this?
Thanks