你能帮我用SQL语句在多个字段中查找重复项吗?
例如,在伪代码中:
select count(field1,field2,field3)
from table
where the combination of field1, field2, field3 occurs multiple times
从上面的陈述if there are multiple occurrences中,我想 Select every record except the first one.
你能帮我用SQL语句在多个字段中查找重复项吗?
例如,在伪代码中:
select count(field1,field2,field3)
from table
where the combination of field1, field2, field3 occurs multiple times
从上面的陈述if there are multiple occurrences中,我想 Select every record except the first one.
要获取有多条记录的字段列表,可以使用..
select field1,field2,field3, count(*)
from table_name
group by field1,field2,field3
having count(*) > 1
有关如何删除行的更多信息,请查看此链接.
http://support.microsoft.com/kb/139444
在使用上面链接中的方法之前,应该有一个标准来决定如何定义"第一行".基于此,如果需要,您需要使用order by子句和子查询.如果你能发布一些样本数据,这将非常有帮助.