标签:函数 多列 font 分组函数 nbsp group by from 情况下 and
我们一般情况下通过分组函数group by来查询重复的列
SELECT [column1],[column2] FROM [dbo].[Table] where 1=1) R group by [column1],[column2] having count(*) > 1
但是查询出的结果不能显示该表的其他列
想要查询一张表中有多个列重复的数据且也要显示该表的其他列
SELECT M.* FROM [dbo].[Table] M, (SELECT * FROM (SELECT [column1],[column2] FROM [dbo].[Table] where 1=1) R group by [column1],[column2] having count(*) > 1) M1 where M.[column1]=M1.[column1] AND M.[column2]=M1.[column2]
标签:函数 多列 font 分组函数 nbsp group by from 情况下 and
原文地址:https://www.cnblogs.com/ruanraun/p/groupby.html