SQL Order By Asc
该语句用于按升序对数据进行排序。如果您没有设置 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 |
这是一个按 NAME 和 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 |
热门文章
优秀文章