SQL-ORDER BY multi-field sorting (ascending, descending), SQL-order ascending

Source: Internet
Author: User

SQL-ORDER BY multi-field sorting (ascending, descending), SQL-order ascending

Order by _ column1, _ column2;/* _ column1 in ascending ORDER, _ column2 in ascending ORDER */order by _ column1, _ column2 DESC;/* _ column1 in ascending ORDER, _ column2 descending ORDER */order by _ column1 DESC, _ column2;/* _ column1 descending ORDER, _ column2 Ascending ORDER */order by _ column1 DESC, _ column2 DESC; /* _ column1 in descending order, _ column2 in descending order */

In SQL, sort by a field in ascending order and then by a field in descending order.

Order by is followed by the first
Order by position, money desc, top desc
Which means
Positions are sorted in ascending order. When positions are equal, they are sorted in descending order of money,
Position and money are sorted by top in descending order

How to sort a field in an SQL table in ascending order

Select * from table name order by field name

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.