sql case when 老是语法报错,请问语法哪错了?SELECT zhu.mingzi,zhu.riqi,zhu.liucheng,zhu.xinghao,zhu.shuliang,casewhen [liucheng] = '点装' then '1'when [liucheng] = '装脚' then '2'when [liucheng] = '只装' then '3'when [liucheng] = '点胶' then '4'when [liucheng] = '切腿' then '5'when [liucheng] = '电测' then '6'when [liucheng] = '全检' then '7'else '8' end AS dj[shuliang]*[danjia] AS zongjiaFROM danjia,zhu;
问题描述:
sql case when 老是语法报错,请问语法哪错了?
SELECT zhu.mingzi,zhu.riqi,zhu.liucheng,zhu.xinghao,zhu.shuliang,
case
when [liucheng] = '点装' then '1'
when [liucheng] = '装脚' then '2'
when [liucheng] = '只装' then '3'
when [liucheng] = '点胶' then '4'
when [liucheng] = '切腿' then '5'
when [liucheng] = '电测' then '6'
when [liucheng] = '全检' then '7'
else '8' end AS dj
[shuliang]*[danjia] AS zongjia
FROM danjia,zhu;
答
access 没有case 语句的,你可以用iif 来实现
SELECT zhu.mingzi, zhu.riqi, zhu.liucheng, zhu.xinghao, zhu.shuliang,
iif(liucheng = '点装',1,
iif(liucheng = '装脚',2,
iif(liucheng = '只装',3,
iif(liucheng = '只装',4,
iif(liucheng = '只装',5,
iif(liucheng = '只装',6,
iif(liucheng = '只装',7,8)
)))))) as dj
[shuliang]*[danjia] AS zongjia
FROM danjia, zhu