Collections:
Sort by Multiple Columns in MySQL
Can the Query Output Be Sorted by Multiple Columns in MySQL?
✍: FYIcenter.com
You can specifying multiple columns in the ORDER BY clause as shown in the following example statement, which returns employees' salaries sorted by department and salary value:
mysql> SELECT tag, counts, url, DATE(created) FROM fyi_links ORDER BY tag, counts; +------+--------+-------------------+---------------+ | tag | counts | url | DATE(created) | +------+--------+-------------------+---------------+ | DBA | 1 | www.mysql.com | 2006-01-01 | | DBA | 3 | dba.fyicenter.com | 2006-07-01 | | DBA | 7 | www.oracle.com | 2005-01-01 | | DEV | 4 | dev.fyicenter.com | 2006-04-30 | | DEV | 4 | www.php.net | 2004-01-01 | | SQA | 6 | sqa.fyicenter.com | 2006-07-01 | | SQA | 8 | www.winrunner.com | 2003-01-01 | +------+--------+-------------------+---------------+ 7 rows in set (0.00 sec)
⇒ Sorting Output in Descending Order in MySQL
⇐ Sorting Query Output in MySQL
2017-11-02, 1437🔥, 0💬
Popular Posts:
Is SQL Server Transact-SQL case sensitive? No. Transact-SQL is not case sensitive. Like the standard...
How To Convert Binary Strings into Integers in SQL Server Transact-SQL? Binary strings and integers ...
What is dba.FYIcenter.com Website about? dba.FYIcenter.com is a Website for DBAs (database administr...
What are binary literals supported in SQL Server Transact-SQL? Binary literals in Transact-SQL are s...
How To Set Up SQL*Plus Output Format in Oracle? If you want to practice SQL statements with SQL*Plus...