我的sql表中有一列。如果值为1则应返回管理资产,否则为非管理资产。这是我的sql代码。
select asset_master_id,
am_name as aname,
am_serial_number as number,
(CASE adm_admin_flag
WHEN 1
THEN "Admin Asset"
ELSE "Non Admin Asset"
END AS am_admin_flag)
FROM asset_master;
我尝试了以上代码,但没有为我工作。
答案 0 :(得分:2)
您的CASE语法错误。
SELECT
CASE
WHEN am_admin_flag = 1
THEN "Admin Asset"
ELSE "Non Admin Asset"
END AS am_admin_flag
FROM
asset_master