SQL Custom Sorting

Source: Internet
Author: User

 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.