[英]SQL union grouped by rows
假设我有一个这样的表:
col1 | col2 | col3 | col4 |
---|---|---|---|
普通话 | 一 | 二 | null |
普通话 | null | null | 三 |
如何产生如下所示的结果:
col1 | col2 | col3 | col4 |
---|---|---|---|
普通话 | 一 | 二 | 三 |
谢谢
像这样,您可以按 col1 分组并获得每组中的最大值:
select col1 , max(col2) col2 , max(col3) col3 , max(col4) col4
from table
group by col1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.