如果fromloc = 1,我想从ReceiveNote中选择,然后打印工厂,否则必须打印其他
SELECT PurDate,
case ReceiveNote.FromLOC
when ReceiveNote.FromLOC = '1' THEN 'Factory'
when ReceiveNote.FromLOC = '2' THEN 'Other'
else ''
end as FromLOC FROM tbl1
答案 0 :(得分:1)
您已在CASE
字后指定了字段。无需再次指定。
SELECT PurDate,
CASE ReceiveNote.FromLOC
WHEN '1' THEN 'Factory'
WHEN '2' THEN 'Other'
ELSE ''
END AS FromLOC
FROM tbl1
答案 1 :(得分:0)
SELECT PurDate,
case when ReceiveNote.FromLOC = '1' THEN 'Factory'
when ReceiveNote.FromLOC = '2' THEN 'Other'
else ''
end as FromLOC FROM tbl1