按DESC排序的SQL 


SQL ORDER BY CLAUSE和DESCENDING ORDER:

该语句用于按降序对数据进行排序。您应该按如下所示在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

这是一个按名称降序对结果进行排序的示例。

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
0



error: 内容受到保护 !!