Answers for "if we use order by in sql for several columns"

SQL
8

sql order by multiple columns

SELECT * FROM table_name ORDER BY col1 ASC;				-- ASCending is default
SELECT * FROM table_name ORDER BY col1 DESC;			-- DESCending
SELECT * FROM table_name ORDER BY col1 DESC, col2;		-- col1 DESC then col2 ASC
Posted by: Guest on May-09-2021
0

t-sql conditional order by multiple columns

SELECT * FROM dbo.Employee
ORDER BY 
 CASE WHEN Gender='Male' THEN EmployeeName END Desc,
 CASE WHEN Gender='Female' THEN Country END ASC
Posted by: Guest on October-07-2020

Code answers related to "if we use order by in sql for several columns"

Code answers related to "SQL"

Browse Popular Code Answers by Language