如何使用NVL将此代码的输出中的空值替换为零?我需要0,这样我就可以对这两列执行加法
horse_wins + jockey_wins目前,如果其中一个值为null,则它们总是等于null。我读到NVL在这种情况下可以提供帮助,但很难实现。
select
race_id,
horse_id,
horse_wins,
jockey_id,
jockey_wins,
horse_wins + jockey_wins
from
proj_entry a
FULL JOIN
tot_h_wins b
ON
a.horse_id = b.horse
FULL JOIN
tot_j_wins c
ON
a.jockey_id = c.jockey
where
race_id = 1
and
where
nvl(jockey_wins, 0);发布于 2014-04-21 15:15:31
select
race_id,
horse_id,
horse_wins,
jockey_id,
jockey_wins,
NVL(horse_wins, 0) + NVL(jockey_wins, 0) wins
from
proj_entry a
FULL JOIN
tot_h_wins b
ON
a.horse_id = b.horse
FULL JOIN
tot_j_wins c
ON
a.jockey_id = c.jockey
where
race_id = 1如果要更改值的显示方式,请不要在where子句中使用NVL。Where用于过滤返回的行。如果要更改显示方式,请在select子句中使用它。
https://stackoverflow.com/questions/23200129
复制相似问题