仅获取前10行

时间:2018-08-20 16:09:52

标签: sql sql-server

我只想从此选择语句中获取前10条记录

SELECT SUM([Order].[Quantity]) As Quantity , [Order].ProductSKU_FK 
FROM [Order]
WHERE [Order].[Status] !='Fulfilled' 
GROUP BY [Order].[ProductSKU_FK] 
ORDER BY Quantity DESC;

1 个答案:

答案 0 :(得分:2)

使用TOP吗?

SELECT TOP 10
    SUM([Quantity]) As Quantity,
    ProductSKU_FK
FROM [Order]
WHERE [Status] != 'Fulfilled'
GROUP BY ProductSKU_FK
ORDER BY Quantity DESC;