数据仓库服务 GAUSSDB(DWS)-单表查询:对结果进行排序

时间:2023-11-22 14:18:32

对结果进行排序

使用ORDER BY语句可以让查询结果按照期望的方式进行排序。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
SELECT product_id,product_name,category,quantity FROM newproducts ORDER BY quantity DESC;
 product_id | product_name |  category   | quantity
------------+--------------+-------------+----------
       3577 | dumbbell     | sports      |      550
       2344 | milklotion   | skin care   |      320
       1666 | Frisbee      | toys        |      244
       1210 | necklace     | jewels      |      200
       1502 | earphones    | electronics |      150
       1700 | interface    | books       |      100
       1601 | telescope    | toys        |       80
(7 rows)
support.huaweicloud.com/devg-820-dws/dws_04_1007.html