合并单个表中的行

时间:2017-10-07 11:20:03

标签: sql merge rows

我有一个看起来像这样的表:

abs0| rel0 | abs1 | rel1
=========================
60  | 0.6  | NULL | NULL 
NULL| NULL |  40  |  0.4

并希望它看起来像这样:

abs0| rel0 | abs1 | rel1
=========================
60  | 0.6  |  40  |  0.4

*此问题已解决

2 个答案:

答案 0 :(得分:1)

你可以使用elide null的聚合函数,例如::

select min(abs0) as abs0, min(rel0) as rel0, min(abs1) as abs1, min(rel1) as rel1
from my_table 

答案 1 :(得分:0)

您可以使用max

SELECT max(c1) AS c1
    ,max(c2) AS c2
    ,max(c3) AS c3
    ,max(c4) AS c4
FROM t1;

<强>结果:

C1   C2     C3   C4
--------------------
60   0.60   40   0.40

您可以查看演示here