我想检索此查询返回的前5行。怎么做
select COUNT(trippackageID), trippackageid
from tbl_holiday_booking
group by trippackageID
答案 0 :(得分:2)
您没有指定订单,您想要预订最多还是最少的包裹?
SELECT TOP 5 COUNT(truppackageID) Num, trippackageid FROM tbl_holiday_booking GROUP BY trippackageID ORDER BY Num DESC
答案 1 :(得分:0)
从....中选择前5 *。
答案 2 :(得分:0)
您可以使用
限制5
答案 3 :(得分:0)
select COUNT(trippackageID) as cnt, trippackageid from tbl_holiday_booking group by trippackageID ORDER BY cnt DESC LIMIT 0,5
实际上,假设你这样做,想要按计数排序,下降(从大到小)。 LIMIT 0,5从第0行开始,并返回接下来的5行。
答案 4 :(得分:0)
SELECT COUNT(trippackageID) AS tpi_c, trippackageid
FROM tbl_holiday_booking
GROUP BY trippackageID
ORDER BY tpi_c DESC
LIMIT 5