【发布时间】:2014-03-19 04:51:53
【问题描述】:
##问题##
此脚本出错 (Postgresql 9.3.2)
(在 MS SQL Server 中没问题)
SELECT
CASE COALESCE(my_date_field,0)
WHEN 0 THEN 0
ELSE 1 END
AS status
FROM
my_table
Error :COALESCE types timestamp without time zone and integer cannot be matchedLine 2 : CASE COALESCE(my_date_field,0)
##已解决##
SELECT
CASE WHEN my_date_field IS NULL
THEN 0 ELSE 1 END
AS status
FROM
my_table
COALESCE 接受几乎任意数量的参数,但它们应该是相同的数据类型。
我引用COALESCE Function in TSQL
【问题讨论】: