1查出姓名,科目,分数相同的记录
select from A as out
where exists(select from
(select a1,a2,a3 from A group by a1,a2,a3 having count() > 1) as b
where a1 = outa1 and a2 = outa2 and a3 = outa3)
2 删出姓名,科目,分数相同的记录(这里应该是重复的记录只保留一条吧)
delete from A
where exists(
select from
(select a1,a2,a3,min(a0) as min_id from A as b
group by a1,a2,a3 having count() > 1) as c
where a1 = Aa1 and a2 = Aa2 and a3 = Aa3 and Aa0 > min_id)
3查出同一个人,语文数学都超过80分,但是只能找出语文数学总分之后最小的那一个
select top 1 a1, ttl from
(select a1,sum(a3) as ttl from A where a2 in (N'语文',N'数学') and a3 > 80
group by a1 having count() = 2 ) as b
order by ttl
楼主您好
select max(sum) from(
select 该列,count(1) sum from table group by 该列 having count(1)>1)
如果结果大于1,则表示存在相同记录
我知道的一个方法。可以建立Synony
同一个Server不同数据库。
例如在A中建立B,C,D的Synony
Create Synonym BH For BH
Create Synonym CH For CH
Create Synonym DH For DH
这样它们就相当于在同一个数据库中了,可以建立连接查询。
以上就是关于数据库SQL高手请进,查找重复数据。全部的内容,包括:数据库SQL高手请进,查找重复数据。、SQL语句来判断数据库某一列下是否有相同值的记录方法、sql2000中,如何来查询多个数据库下面的相同个表的内容等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)