比如我表里的两条数据是 ID VALUE TYPE 1 a 0 2 b 0 sql查询完变成 ID VALUE TYPE 1 2 a b 这样类似的功能不知道能不能通过sql实现
--ID VALUE TYPE --1 a 0 --2 b 0 with t as( select 1 as id,'a' as value,0 as type from dual union all select 2,'b',0 from dual) select listagg(id) within group (order by 1) as id,listagg(value) within group (order by 1) as value from t
minus
select b.col1 from b
比如我表里的两条数据是
ID VALUE TYPE
1 a 0
2 b 0
sql查询完变成
ID VALUE TYPE
1 2 a b
这样类似的功能不知道能不能通过sql实现
--1 a 0
--2 b 0
with t as(
select 1 as id,'a' as value,0 as type from dual
union all
select 2,'b',0 from dual)
select listagg(id) within group (order by 1) as id,listagg(value) within group (order by 1) as value from t
感觉跟我想象中的还有有差距,我试着把你的sql改了一下,这个只能在确定了哪一个字段被修改了之后才能用,我想实现的功能是通过sql确定出哪一列变了,然后变了的合并起来,不知道能不能实现
1 a 0
2 b 0
哦,你上面的两条值有一条是更改之前的值,有一条是更改之后的值?
如果还有一条记录
3 c 0
你怎么区分是哪条改了哪条?
select * from t where exists (select 1 from t t1 where t.id=t1.id and t.xx != t1.xx )
)
group by id