SQL server 数据分组后排序
代码:
select
StudentID,SolutionID,Correct,Score,ProblemID,ProblemTitle,AssignmentTitle,LateSubmission
from ONE
where Correct=1 AND Score=1
group by StudentID,ProblemID
order by SolutionID desc
报错:
消息 8120,级别 16,状态 1,第 385 行
选择列表中的列 'ONE.SolutionID' 无效,因为该列没有包含在聚合函数或 GROUP BY 子句中。
想了好久也没解决
我想按ProblemID分组之后按StudentID分组,再按SolutionID排序
select指定的每一列都应该出现在group by中,除了对使用了聚合函数的列