Search
 
SCRIPT & CODE EXAMPLE
 

SQL

order by sql

//this_for_descending_order.. 
 SELECT * FROM TableName ORDER BY columnName DESC;
 // this_for_ascending_order..
SELECT * FROM TableName ORDER BY columnName ASC;
Comment

sort by sql

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
Comment

SQL ORDER BY ASC (Ascending Order)

SELECT *
FROM Customers
ORDER BY age ASC;
Comment

SQL ORDER BY With WHERE

SELECT last_name, age
FROM Customers
WHERE NOT country = 'UK'
ORDER BY last_name DESC;
Comment

sql query order

SQL order of execution defines the
execution order of clauses.

-Select
It starts execution with 
-from  (Choose and join tables to get base data)
after from
-where ( filters base data )
-group by (Aggregates base data)
-having (filters aggregated data)
-select (returns final data)
-order by (sorts the final data)
-limit (limits the returned data to a row count)

Only select and from are mandatory
Comment

sql order by

Used to sort the result data in ascending (default) or descending order
through the use of ASC or DESC keywords.
Example: Returns countries in alphabetical order.
SELECT * FROM countries
ORDER BY name;
Comment

SQL ORDER BY Clause

SELECT *
FROM Customers
ORDER BY first_name;
Comment

sorting desc in sql

order by statement in sql
Comment

order by in sql

ORDER BY: is for sorting result
either in descending or ascending order.
Comment

PREVIOUS NEXT
Code Example
Sql :: how to insert multiple rows in sql 
Sql :: Select without null values sql 
Sql :: python sqlite data delete 
Sql :: sql datetime format 
Sql :: The local psql command could not be located 
Sql :: Check database restore status sql script 
Sql :: sql convert datetime to year 
Sql :: change filed order in mysql 
Sql :: output table plsql 
Sql :: mysql decimal allow negative values? 
Sql :: sql paging query 
Sql :: mysql grant all on all databases 
Sql :: mysql permissions 
Sql :: activate event scheduler mariadb 
Sql :: delete a temporary table mysql 
Sql :: create table in mysql mariadb primary key foreign key 
Sql :: create table in sql server 
Sql :: how to drop database name in postgresql 
Sql :: com.mysql.cj.exceptions.InvalidConnectionAttributeException more than one time zone. You must configure either the server or JD value if you want to utilize time zone support. 
Sql :: postgresql grant owner to user 
Sql :: display all node label neo4j 
Sql :: setval max id postgresql sequence 
Sql :: mysql create table from select statement 
Sql :: Client does not support authentication protocol requested by server; consider upgrading MySQL client 
Sql :: find number of entries sql 
Sql :: mysql case 
Sql :: add not null constraint sql server 
Sql :: SQL COUNT() with WHERE 
Sql :: mysql add columns 
Sql :: postgresql function round 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =