我将如何正确地做到这一点:
顾客
CusID, CusLname, CusFname, CusMname, CusAddress, CusEmailAdd
命令
OrderID, Order, CusID
SQL
Select Count(OrderID), o.CusID, CusLname, CusFname, CusMname, CusAddress, CusEmailAdd
From Customer c
Inner join
Order o
On c.CusID = o.CusID
Group By o.CusID
错误
Column 'CusLname, CusFname, CusMname, CusAddress, CusEmailAdd' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
为什么我需要在 Group By 子句中添加这些列?由于我只想按 CusID 对它们进行分组,我将如何选择这些列而不将它们包含在 Group By 中?