【发布时间】:2017-11-03 04:47:39
【问题描述】:
我正在 Postgres 中编写一个 select 语句,其中包含 case 语句如下:
,(case when all_loc.country = 'DE' then msc_si.buyer_id else msc_si.buyer_name end) as "purchasing_group_name_buyer_name" --story
,(case when all_loc.country = 'DE' then msc_si.planner_code else mscp.description end) as "mrp_controller_name" --story
我收到以下错误。我尝试使用IS 而不是=,但没有奏效。如果没有这两个 case 语句,查询将完美运行。
错误:CASE 类型的字符变化和数字不能匹配 SQL 状态:42804
【问题讨论】:
-
@a_horse_with_no_name,我觉得不是比较问题,我觉得是类型输出问题。也就是说,我假设
msc_si.buyer_name是一个字符串,msc_si.buyer_id是一个数字。
标签: sql postgresql select case