多行合并的问题

Excalibur_丨Avalon 2019-01-16 05:47:27
假设有表 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语句怎么写急急急

...全文
89 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
weixin_44200964 2019-01-17
  • 打赏
  • 举报
回复
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
nayi_224 2019-01-16
  • 打赏
  • 举报
回复
select col1, max(col2), max(col3) from tab1 group by col1;
  • 打赏
  • 举报
回复
自己顶一下!!!!!!!!!!!

17,078

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧