假設有表 t
col1 col2 col3
-------------------
a t null
a null s
b t null
b null s
期望的得到的結果集
col1 col2 col3
--------------------
a t s
b t s
請問sql陳述句怎么寫急急急
uj5u.com熱心網友回復:
自己頂一下!!!!!!!!!!!uj5u.com熱心網友回復:
select col1, max(col2), max(col3) from tab1 group by col1;uj5u.com熱心網友回復:
with tmp as
(select 'a' as col1,'t' as col2, null as col3 from dual
union all
select 'a' as col1,null as col2, 's' as col3 from dual
union all
select 'b' as col1,'t' as col2, null as col3 from dual
union all
select 'b' as col1,null as col2, 's' as col3 from dual
)
select col1,
max(col2) col2,
max(col3) col3
from tmp
group by col1
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/54035.html
標籤:開發
