答案 0 :(得分:1)
您可以使用聚合:
select max(id1) as id1, max(id2) as id2, max(id3) as id3
from . . .
答案 1 :(得分:1)
我希望在这里使用SUM()
,因为您可能在给定列中包含负数:
select sum(id1) as id1, sum(id2) as id2, sum(id3) as id3
from yourTable
如果我们使用MAX()
,则会失败,例如,其中一列中有-2
。在这种情况下,最大值将返回零。
答案 2 :(得分:0)
我不确定该解决方案是否适合执行,但是:
select (select id1 from table where id1 <> 0) id1,
(select id2 from table where id2 <> 0) id2,
(select id3 from table where id3 <> 0) id3
from dual;