0

我有一个 postgres 视图,它返回以“Y”或“N”为值的记录,我想在返回最终 SQL 结果之前将它们转换为“是”或“否”。例如:

    CREATE OR REPLACE VIEW transit_info AS 
 SELECT 
 ('Train Service:'::text || tblpoi_transit_info.train_service::text AS train_service,

我想根据记录的值将 train_service 转换为“是”或“否”。有什么方法可以轻松做到这一点?我一直在试验 CASE 语句,但还没有真正掌握语法。谢谢。

4

1 回答 1

1
SELECT 
    ('Train Service:'::text
    ||
    case tblpoi_transit_info.train_service::text
        when 'Y' then 'Yes' else 'No'
    end AS train_service,
于 2012-12-27T18:36:49.617 回答