我在查询时尝试将NULL
作为字符串返回到视图中,但并不是真的了解如何。
对于列,它要么有数据要么返回NULL
,但是如果它返回NULL
我想要它说些别的话。
SELECT lib_item_id "Library Item ID",
title "Library Item Name",
date_of_purchase "Year of Purchase",
coalesce(pub_id, null) as "Publisher ID"
FROM lib.Library_items
WHERE date_of_purchase > '31-DEC-10'
ORDER BY "Library Item Name" asc;
答案 0 :(得分:3)
使用
select coalesce(some_column, 'some default string') as some_column
from your_table
或
select case when some_column is null
then 'some default string'
else some_column
end as some_column
from your_table