标签:
SELECT id, 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 WHEN TIMESTAMPDIFF( MINUTE, SYSDATE(), CONCAT( send_date, ‘ ‘, SUBSTR(end_time FROM 1 FOR 2), ‘:‘, SUBSTR(end_time FROM 3 FOR 4), ‘:00‘ ) ) < 0 THEN ‘2‘ ELSE status END AS status, line_id, create_time, update_time, del_flag, spare1, spare2, spare3, spare4, spare5, spare6, spare7, spare8, spare9, spare10 FROM u_custom_line <include refid="SelectSQL" ></include> ORDER BY (CASE (CASE WHEN TIMESTAMPDIFF( MINUTE, SYSDATE(), CONCAT( send_date, ‘ ‘, SUBSTR(end_time FROM 1 FOR 2), ‘:‘, SUBSTR(end_time FROM 3 FOR 4), ‘:00‘ ) ) < 0 THEN ‘2‘ ELSE status END) 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), ‘:00‘ ) DESC
标签:
原文地址:http://www.cnblogs.com/bifenghui/p/4964039.html