- 我想要一个结果集,会告诉我由供应商分组的发票。
- 我想要一个结果集,会告诉我的供应商,他们已经为了开发票从最低金额开具发票发票量最多的总量。
- 我想要的结果集,其中显示了一个总金额超过$ 2000.00更大的供应商,他们已开具发票的总金额。
Select * from Invoices group by VendorID;
Select Vendors.VendorID,Vendors.VendorName,sum(Invoices.InvoiceTotal)
from Vendors inner join Invoices on Vendors.VendorID = Invoices.VendorID group by Vendors.VendorID order by sum(Invoices.InvoiceTotal);
Select Vendors.VendorID,Vendors.VendorName,sum(Invoices.InvoiceTotal)
from Vendors inner join Invoices on Vendors.VendorID = Invoices.VendorID group by Vendors.VendorID having sum(Invoices.InvoiceTotal) > 2000;
此代码给了我同样的错误:需要帮助搞清楚什么是错我的代码
Msg 8120, Level 16, State 1, Line 2
Column 'Invoices.InvoiceID' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
Msg 8120, Level 16, State 1, Line 4
Column 'Vendors.VendorName' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
Msg 8120, Level 16, State 1, Line 8
Column 'Vendors.VendorName' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
请出示你到目前为止试图解决这个问题。请参阅[如何调试小程序(https://ericlippert.com/2014/03/05/how-to-debug-small-programs/)。 – Xufox
请编辑你的问题,并给它一个有意义的标题。大家谁问了一个问题在这里_Need帮助搞清楚什么是错我的code_ – baao