如何在查询中省略空值?

时间:2016-11-20 13:23:12

标签: sqlplus

我正在尝试将这些值放在一列中,但有时“县”没有值。如何才能使它不显示为Name_of_town,邮政编码?

ROTFLAGS_REGISTRATIONKEEPSALIVE

这是我目前从查询中获得的内容。 (','本身的示例在第一个查询结果上)

SQL> select SuppName || ', ' || Street || ', ' || Town || ', ' || County || ', ' || PostCode AS "Supplier Address"
2  from Suppliers
3  ORDER BY 1;

1 个答案:

答案 0 :(得分:0)

似乎甲骨文的NVL是可行的方式。它将使用您选择的字符串替换空值。我假设当你说县没有价值时,该字段包含null。 Otherwice oracle REPLACE可行。

NVL

试试这个:

select SuppName || ', ' || Street || ', ' || Town || ', ' || NVL(County, 'No_County') || ', ' || PostCode AS "Supplier Address"
from Suppliers
ORDER BY 1;