[英]Using TOP in select statements SQL
I'm trying to return only 10 rows, corresponding to the 10 vendors who've been paid the most but I can't seem to figure out how to use the TOP clause to grab the top 10 vendors who've been paid the most. 我只想返回10行,对应于获得最高报酬的10个供应商,但我似乎无法弄清楚如何使用TOP子句来获取获得最高报酬的前10个供应商。 。
Select Top 10 SUM(PaymentTotal) AS PaymentSum, VendorName
From Invoices JOIN Vendors
On Vendors.VendorID = Invoices.VendorID
Group By VendorName;
Select Top 10
sum(PaymentTotal) AS PaymentSum,
VendorName
From
Invoices
INNER JOIN Vendors On Vendors.VendorID = Invoices.VendorID
Group By
VendorName
Order By
sum(PaymentTotal) desc
;
Select Top 10 SUM(PaymentTotal) AS PaymentSum, VendorName
From Invoices JOIN Vendors
On Vendors.VendorID = Invoices.VendorID
Group By VendorName
order by PaymentSum dsec;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.