SQL ORDER BY Keyword

SHOW Table:

select * from employeeinfo;

name age address salary
Komal 25 Mumbai 5000
Ramesh 35 Delhi 4500
Kaushik 31 Indore 10000
Hardik 22 Hyderabad 8500
Aishwarya 28 Bangalore 6500
Akshaya 29 Delhi 5000

ORDER By:

select * from employeeinfo ORDER BY name ASC;

name age address salary
Akshaya 29 Delhi 5000
Glory 28 Kanpur 6500
Hardik 22 Hyderabad 8500
Kaushik 31 Indore 10000
Komal 25 Mumbai 5000
Ramesh 35 Delhi 4500

select * from employeeinfo ORDER BY name DESC;

name age address salary
Ramesh 35 Delhi 4500
Komal 25 Mumbai 5000
Kaushik 31 Indore 10000
Hardik 22 Hyderabad 8500
Glory 28 Kanpur 6500
Akshaya 29 Delhi 5000

Leave a Reply

Your email address will not be published. Required fields are marked *