about selecting rows
Posted: Wed Aug 18, 2004 2:40 am
i have a table which has three columns
station_id,arrival_time,departure_time
now the sample data is like this
now if the current time is 1:45 then i want to search through the table the most nearest but less departure time like in this case iy should give result
1:40 and
12:30
it gives 12:30 also because 1:45 time occurs twice in this time scheme
the first occurance gives 1:40 and if there is second occurance then it also gives second nearest i.e. 12:30 and if there is a third occurance then it should also give third nearest time.
any1 can tell me wat query shud i use or wat is the strategy to get the desired result.
station_id,arrival_time,departure_time
now the sample data is like this
Code: Select all
st_id dep_time arr_time
23 11:10 11:20
25 1:30 1:40
45 6:20 6:45
31 10:40 10:45
34 12:20 12:30
21 4:10 4:151:40 and
12:30
it gives 12:30 also because 1:45 time occurs twice in this time scheme
the first occurance gives 1:40 and if there is second occurance then it also gives second nearest i.e. 12:30 and if there is a third occurance then it should also give third nearest time.
any1 can tell me wat query shud i use or wat is the strategy to get the desired result.