[英]MYSQL CASE STATEMENT MULTIPLE CONDITIONS
Please help to check the error in following sql code: 请帮助检查以下sql代码中的错误:
select
case when (z.mso_group_id = '3' and z.model_id = '22887081') then coalesce(level_2_id,996) level_2_id
when (z.mso_group_id = '4' and z.model_id = '22911859') then coalesce(level_2_id,997) level_2_id
when (z.mso_group_id = '5' and z.model_id = '22915074') then coalesce(level_2_id,998) level_2_id
when (z.mso_group_id = '2' and z.model_id = '22908275') then coalesce(level_2_id,999) level_2_id
end level_2_id
from
database_name
You are repeating the column alias. 您正在重复列别名。 Do you intend this? 你打算这个吗?
select (case when (z.mso_group_id = '3' and z.model_id = '22887081') then coalesce(level_2_id,996)
when (z.mso_group_id = '4' and z.model_id = '22911859') then coalesce(level_2_id,997)
when (z.mso_group_id = '5' and z.model_id = '22915074') then coalesce(level_2_id,998)
when (z.mso_group_id = '2' and z.model_id = '22908275') then coalesce(level_2_id,999)
end) as level_2_id
from database_name;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.