sql 表中怎么根据多个字段查询重复数据,

2024-10-30 15:33:22
有5个网友回答
网友(1):

查重复的数据

select a,b,c,d,e,f
from a
group by a,b,c,d,e,f
having count(*)>1

正解~!~
在oracle 中剔重查数据sql
select a, b, c, d, e, f from (select a, b, c, d, e, f, row_number() over(partition by a,b,c,d,e,f order by rowid) rn
from a) t where rn = 1;

网友(2):

select max(a),max(b)等字段 from A
group by a,b,c,d
max 是聚合函数··
如果值是数字 建议换个聚合函数就行··

网友(3):

select a,b,c,d,e,f
from a
group by a,b,c,d,e,f
having count(*)>1

正解~!~

网友(4):

使用 degree字段分组查询,再 top 3
select top 3 degree,count(degree) as 人数
from student
group by degree
order by degree

网友(5):

select a,b,c,d,e,f
from a
group by a,b,c,d,e,f
having count(*)>1