3,491
社区成员
发帖
与我相关
我的任务
分享
with tb as
(select 1 id,'zhang' name from dual union all
select 1,'zhang' from dual union all
select 2,'wang' from dual union all
select 2,'li' from dual union all
select 3,'li' from dual union all
select 4,'zhao' from dual)
select id,name
from tb a where exists(select 1 from tb b where a.id=b.id and a.name<>b.name
)
select name,sum(decode(subject,'语文',grant)) "语文",
sum(decode(subject,'数学',grant)) "数学",
sum(decode(subject,'外语',grant)) "外语",
sum(decode(subject,'地理',grant)) "地理"
from tb
group by name
select * from temp where id in(
select id from (
select id,name,row_number() over(partition by id,name order by name) rn from temp
) group by id,rn having count(rn) = 2)