About sorting issues

Source: Internet
Author: User
Let's say there are 2 fields, 1 is the time, the ID.
ID time




I'd like to order by ID first.

3 444
3 555

2 222
2 333

And then order by time.

Become
3 444
3 555

2 333
2 222

How to write note 33 22 are grouped to sort the


Reply to discussion (solution)

If the final result is this, you can write the order by ID desc,time desc
3 555
3 444
2 333
2 222

Whether your request is:
Time Ascending of Odd ID
Time descending for even ID

If so, the order clause is:
ORDER BY id DESC, id%2

  • 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.