Collections:
Sorting Output in Descending Order in MySQL
How To Sort Output in Descending Order in MySQL?
✍: FYIcenter.com
If you want to sort a column in descending order, you can specify the DESC keyword in the ORDER BY clause. The following SELECT statement first sorts the "tag" in descending order, then sorts the "counts" in ascending order:
mysql> SELECT tag, counts, url, DATE(created) FROM fyi_links ORDER BY tag DESC, counts; +------+--------+-------------------+---------------+ | tag | counts | url | DATE(created) | +------+--------+-------------------+---------------+ | SQA | 6 | sqa.fyicenter.com | 2006-07-01 | | SQA | 8 | www.winrunner.com | 2003-01-01 | | DEV | 4 | dev.fyicenter.com | 2006-04-30 | | DEV | 4 | www.php.net | 2004-01-01 | | DBA | 1 | www.mysql.com | 2006-01-01 | | DBA | 3 | dba.fyicenter.com | 2006-07-01 | | DBA | 7 | www.oracle.com | 2005-01-01 | +------+--------+-------------------+---------------+ 7 rows in set (0.01 sec)
⇒ Count Number of Rows with SELECT Statements in MySQL
⇐ Sort by Multiple Columns in MySQL
2017-11-02, 2145🔥, 0💬
Popular Posts:
What Is an Oracle Tablespace in Oracle? An Oracle tablespace is a big unit of logical storage in an ...
Is SQL Server Transact-SQL case sensitive? No. Transact-SQL is not case sensitive. Like the standard...
What is dba.FYIcenter.com Website about? dba.FYIcenter.com is a Website for DBAs (database administr...
What Are the Underflow and Overflow Behaviors on FLOAT Literals in SQL Server Transact-SQL? If you e...
What is SQL Server Transact-SQL (T-SQL)? SQL Server Transact-SQL, also called T-SQL, is an extension...