某表Table1有一字段F2有重复记录,我想得到F2没有重复的记录(有重复的记录一条也不要)。自己倒是写了一个语句:Select G.* From (Select A.F2, Count(A.F1) From Table1 As A Group By A.F2 Having (Count(*) = 1)) As G这个语句效率太低,对于大数据量足足用了5分钟。请教更有效的语句。谢谢!
调试欢乐多
select * from Table1 where F2 not exists(select F2 from Table1 group by F2 having count(F2)>1)
select * from Table1 where F2 not exists(select F2 from Table1 a where table1.f2=a.f2 group by F2 having count(F2)>1)
inner join
(select id from [user] a where exists(select 1 from [user]
where name = a.name group by name having count(*) > 1)) as b
on t.id = b.id