SQL ORDER BY ASC 


SQL子句按升序排列

该语句用于按升序对数据进行排序。如果您错过了ASC属性,则默认情况下SQL ORDER BY查询将采用升序。

让我们以供应商为例

SELECT supplier_city
FROM suppliers
WHERE supplier_name = 'IBM'
ORDER BY supplier_city;

让我们看一个具有以下记录的CUSTOMERS表:

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

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

SELECT * FROM CUSTOMERS
ORDER BY NAME, SALARY;

这将产生以下结果。

ID NAME AGE ADDRESS SALARY
3 Ajeet bhargav 45 Meerut 65000
5 Balwant singh 45 Varanasi 36000
1 Himani gupta 21 Modinagar 22000
6 Mahesh sharma 26 Mathura 22000
4 Ritesh yadav 36 Azamgarh 26000
2 Shiva tiwari 22 Bhopal 21000
0



error: 内容受到保护 !!