查找表中的重复行我试过这个查询来获取重复记录。但是我得到这个错误。如何使用sql
select * from Codes
where id = 35712 and isactive = 1
group by line_num
having count(*) > 1
我得到这个错误。
Msg 8120, Level 16, State 1, Line 1
Column 'Codes.code_id' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
此处code_id是此表的主键。
任何人都可以帮我解决如何获取这个表中有重复的code_id。
由于
如果我用主键组合,我没有得到任何记录。 – user957178
如果code_id是主键,那么pair:code_id,line_num并不总是唯一的? –
如果id是您的主键,则不能有多于一行的id为35712. – nos