SQL Order By Desc
SQL Order By Desc 语句用于按降序对数据进行排序。您应该在 ORDER BY 子句中使用 DESC 属性,如下所示。
SELECT supplier_city
FROM suppliers
WHERE supplier_name = 'IBM'
ORDER BY supplier_city DESC;
让我们看一个员工表的例子:
ID | NAME | AGE | ADDRESS | SALARY |
---|---|---|---|---|
1 | Himani gupta | 21 | Modinagar | 22000 |
2 | Shiva tiwari | 22 | Bhopal | 21000 |
3 | Ajeet bhargav | 45 | Meerut | 65000 |
4 | Ritesh yadav | 36 | Azamgarh | 26000 |
5 | Balwant singh | 45 | Varanasi | 36000 |
6 | Mahesh sharma | 26 | Mathura | 22000 |
这是一个按 NAME 对结果进行降序排序的示例。
SELECT * FROM CUSTOMERS
ORDER BY NAME DESC;
这将产生以下结果。
ID | NAME | AGE | ADDRESS | SALARY |
---|---|---|---|---|
2 | Shiva tiwari | 22 | Bhopal | 21000 |
4 | Ritesh yadav | 36 | Azamgarh | 26000 |
6 | Mahesh sharma | 26 | Mathura | 22000 |
1 | Himani gupta | 21 | Modinagar | 22000 |
5 | Balwant singh | 45 | Varanasi | 36000 |
3 | Ajeet bhargav | 45 | Meerut | 65000 |
热门文章
优秀文章