SELECTID, User_mobile, start_province_id, start_city_id, start_county_id, Start_station, end_province_id, end _city_id, end_county_id, End_station, Send_date, Start_time, End_time , Case whenTimestampdiff (MINUTE, Sysdate (), CONCAT (Send_date,' ', SUBSTR (End_time from 1 for 2), ':', SUBSTR (End_time from 3 for 4), ': xx' ) ) &Lt0 Then '2' ELSEStatusEND asstatus, line_id, Create_time, Update_time, Del_flag, Spare1, Spare2, Spare3, Spare4, Spare5, Spare6, SP Are7, Spare8, Spare9, Spare10 fromU_custom_line<Include refID="Selectsql"></Include> ORDER by ( Case ( Case whenTimestampdiff (MINUTE, Sysdate (), CONCAT (Send_date,' ', SUBSTR (End_time from 1 for 2), ':', SUBSTR (End_time from 3 for 4), ': xx' ) ) &Lt0 Then '2' ELSEStatusEND) when '1' Then 1 when '0' Then 2 when '2' Then 3 End)ASC, CONCAT (Send_date,' ', SUBSTR (End_time from 1 for 2), ':', SUBSTR (End_time from 3 for 4), ': xx' ) DESC
SQL Custom Sorting