我有三张桌子
表格1:
tblCustomer
CustomerID CustomerName
1 ABC Bank
2 Chase Bank
表 2:
tblOrderType
OrderTypeID OrderTypeName
1 Assignment
2 LienRelease
表3:
tblOrder
OrderID CustomerID OrderTypeID LoanNumber
1 1 1 45584565
2 1 1 45566856
3 1 1 45565584
4 1 1 45588545
我正在尝试按顺序返回CustomerID
,和CustomerName
,但是在使用以下查询时:OrderTypeName
OrderCount
CustomerName
SELECT tblOrder.CustomerID,CustomerName,OrderTypeName,COUNT(tblOrder.CustomerID) FROM tblOrder
INNER JOIN tblCustomer ON tblOrder.CustomerID=tblCustomer.CustomerID
INNER JOIN tblOrderType ON tblOrder.OrderTypeID=tblOrderType.OrderTypeID
GROUP BY tblOrder.CustomerID
我收到错误消息:
Column 'tblCustomer.CustomerName' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
我不知道我做错了什么。