如何使用group by,使用join语句在SQL Server中按语句排序
问题描述:
我想使用join连接两个表,并让用户按升序排序并对列进行分组。当我写这个语句时没有错误但是当我执行时我得到一个错误说
列'TableName.ColumnID'在选择列表中无效,因为它不包含在聚合函数中或者GROUP BY子句。请解释我任何人
我尝试过:
i wan to join two tables using join, and letting the user to order by ascending order with grouping the columns. When i was writing this statement no error but when i execute then i am getting an error saying
"Column 'TableName.ColumnID' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.". Please explain me anyone
What I have tried:
SELECT FT.Column, FT.ColumnID
FROM FirstTable AS FT
JOIN SecondTable AS ST
ON FT.ColumnID = ST.ColumnID
GROUP BY FT.Column
ORDER BY FT.NUMBER ASC