Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- best_time_id int(10)
- lap_id int(11)
- start_time int(10)
- end_time int(10)
- total_distance decimal(7,2)
- total_elapsed_time decimal(11,2)
- SELECT `bt`.`total_distance`, `bt`.`total_elapsed_time`, `bt`.`start_time`
- FROM `best_times` AS `bt`, `laps` AS `l`
- WHERE (
- SELECT COUNT(*) FROM `best_times` AS `bt2`
- WHERE `bt2`.`total_distance` = `bt`.`total_distance`
- AND `bt2`.`total_elapsed_time` <= `bt`.`total_elapsed_time`
- AND `bt2`.`start_time` > `bt`.`start_time`
- ) <= 10 AND `l`.`lap_id` = `bt`.`lap_id` AND `l`.`car_id` = 1 ORDER BY `bt`.`total_distance` ASC, `bt`.`total_elapsed_time` desc
- | total_distance | total_elapsed_time | start_time |
- |----------------|--------------------|------------|
- | 1000.00 | 99.15 | 1431344798 |
- | 1000.00 | 98.25 | 1431604966 | This record shouldn't be here because although it's quicker it happened after the 91.40 time
- | 1000.00 | 91.40 | 1431433535 |
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement