I want to quickly show the next 4 departures from a bus timetable where some buses run every 5 minutes while others run every hour.
Is it possible to select in only ONE SQL statement from a large table containing all the departures for a week?
Eg if there are 100 buses then the record set should return maximum only 400 rows irrespective of the frequency of bus departures.
TOP 400 seems only good for the total records, sorting by time gives different numbers for different routes.
Something like repeating a query 100 times counting each route until 4 each are found would be rather slow.
Is it possible to select in only ONE SQL statement from a large table containing all the departures for a week?
Eg if there are 100 buses then the record set should return maximum only 400 rows irrespective of the frequency of bus departures.
TOP 400 seems only good for the total records, sorting by time gives different numbers for different routes.
Something like repeating a query 100 times counting each route until 4 each are found would be rather slow.