如何将 return NULL 作为 SQL 查询结果中的特定字符串?

How to return NULL as a specific string in a SQL query result?

我正在尝试在查询时将 return NULL 作为视图中的字符串,但并不真正理解如何实现。

对于该列,它有数据或 returns NULL,但如果它 returns 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;

使用

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