-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathORDER BY Descending order in SQL.txt
More file actions
31 lines (29 loc) · 1.44 KB
/
ORDER BY Descending order in SQL.txt
File metadata and controls
31 lines (29 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// ORDER BY descending order
This is used to sort the recorde.
ASC -> It sort in ascending order (by default)
DESC -> It sort in descending order.
1. Sort in descending order
Syntax: SELECT * FROM student_reg ORDER BY column_name DESC;
ex: select * from student_reg ORDER BY name DESC;
+------+---------+---------+------------+-----------+
| s_id | name | address | dob | fees |
+------+---------+---------+------------+-----------+
| 106 | SITA KC | PKR | 1998-02-02 | 20000.12 |
| 102 | SITA | KTM | 2001-10-11 | 200000.12 |
| 101 | RAM | KTM | 1998-12-15 | 1000.23 |
| 105 | KAMAL | PKR | 1956-12-12 | 100000.12 |
| 103 | HARI | PKR | 2001-01-12 | 10000.52 |
| 104 | BIMAl | KTM | NULL | 1001.23 |
+------+---------+---------+------------+-----------+
// ORDER BY Asecending
ex: select * from student_reg ORDER BY name ASC;
+------+---------+---------+------------+-----------+
| s_id | name | address | dob | fees |
+------+---------+---------+------------+-----------+
| 104 | BIMAl | KTM | NULL | 1001.23 |
| 103 | HARI | PKR | 2001-01-12 | 10000.52 |
| 105 | KAMAL | PKR | 1956-12-12 | 100000.12 |
| 101 | RAM | KTM | 1998-12-15 | 1000.23 |
| 102 | SITA | KTM | 2001-10-11 | 200000.12 |
| 106 | SITA KC | PKR | 1998-02-02 | 20000.12 |
+------+---------+---------+------------+-----------+