数据仓库服务 GAUSSDB(DWS)-GaussDB(DWS)单表查询:限制结果查询数量

时间:2024-10-28 14:23:05

限制结果查询数量

如果需要查询只返回部分结果,可以使用LIMIT语句限制查询结果返回的记录数。

1
2
3
4
5
6
7
8
9
SELECT product_id,product_name,category,quantity FROM newproducts ORDER BY quantity DESC limit 5;
 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
(5 rows)
support.huaweicloud.com/devg-dws/dws_04_1007.html