- 我想要一個結果集,會告訴我由供應商分組的發票。
- 我想要一個結果集,會告訴我的供應商,他們已經爲了開發票從最低金額開具發票發票量最多的總量。
- 我想要的結果集,其中顯示了一個總金額超過$ 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