SELECT MAX(R.Stage),D.CarID,D.RecordID FROM Repayinfo as R,CustomerBaseInfo as C,CustomerCarInfo as D where R.RecordID=C.RecordID and C.Address like '%城区%' and R.RepayKind='CarLoan' GROUP BY D.CarID ORDER BY D.CarID不好意思,看一下线在这一句,在查询分析器中出现下面错误提示服务器: 消息 8120,级别 16,状态 1,行 1
列 'D.RecordID' 在选择列表中无效,因为该列既不包含在聚合函数中,也不包含在 GROUP BY 子句中。
列 'D.RecordID' 在选择列表中无效,因为该列既不包含在聚合函数中,也不包含在 GROUP BY 子句中。
FROM Repayinfo as R,CustomerBaseInfo as C,CustomerCarInfo as D
where R.RecordID=C.RecordID and C.Address like '%城区%' and R.RepayKind='CarLoan'
GROUP BY D.CarID
ORDER BY D.CarID--没问题啊,你仔细看看表结构
GROUP BY D.CarID ,D.RecordID --notice
ORDER BY D.CarID
FROM Repayinfo as R,CustomerBaseInfo as C,CustomerCarInfo as D
where R.RecordID=C.RecordID and C.Address like '%城区%' and R.RepayKind='CarLoan'
GROUP BY D.CarID
ORDER BY D.CarID或
SELECT MAX(R.Stage),D.CarID,D.RecordID
FROM Repayinfo as R,CustomerBaseInfo as C,CustomerCarInfo as D
where R.RecordID=C.RecordID and C.Address like '%城区%' and R.RepayKind='CarLoan'
GROUP BY D.CarID ,D.RecordID --加到group by 中
ORDER BY D.CarID