case
when (出勤天数 + round(( 行政 + 周末 + 法定 )/ 8.0,1) ) >=15 then
case
when 岗位 in ('AA工','SS班长') and 部门编号 not in (select 部门编号 from 部门表 where substring(部门编号,1,3) in ('10508'))
then 0
when 岗位 in ('YY组长') and 部门编号 not in (select 部门编号 from 部门表 where substring(部门编号,1,3) in('10509','10510'))
then 0
else 补贴
end
else 0
end
when (出勤天数 + round(( 行政 + 周末 + 法定 )/ 8.0,1) ) >=15 then
case
when 岗位 in ('AA工','SS班长') and 部门编号 not in (select 部门编号 from 部门表 where substring(部门编号,1,3) in ('10508'))
then 0
when 岗位 in ('YY组长') and 部门编号 not in (select 部门编号 from 部门表 where substring(部门编号,1,3) in('10509','10510'))
then 0
else 补贴
end
else 0
end
then
case
when 岗位 in ('AA工','SS班长') and 部门编号 not in (select 部门编号 from 部门表 where substring(部门编号,1,3) in ('10508'))
then 0
when 岗位 in ('YY组长') and 部门编号 not in (select 部门编号 from 部门表 where substring(部门编号,1,3) in('10509','10510'))
then 0
else 补贴
end
else 0 end
排一下格式
case when 岗位 in ('AA工','SS班长') and 部门编号 not in (select 部门编号 from 部门表 where substring(部门编号,1,3) in ('10508'))
then 0
when 岗位 in ('YY组长') and 部门编号 not in (select 部门编号 from 部门表 where substring(部门编号,1,3) in('10509','10510'))
then 0
else 补贴 end
else 0
end
语法是没有问题的。
不过 substring(部门编号,1,3) in('10509','10510') 这个能有结果吗。
substring(部门编号,1,3) 得长度最多为3,和'10509' 为什么 等长度为5 得内容比较 ?
substring(部门编号,1,3) in ('10508')
substring(部门编号,1,3) in ('10509','10510')
(case when 岗位 in ('AA工','SS班长') and 部门编号 not in (select 部门编号 from 部门表 where substring(部门编号,1,3) in ('10508')) then 0
when 岗位 in ('YY组长') and 部门编号 not in (select 部门编号 from 部门表 where substring(部门编号,1,3) in('10509','10510')) then 0
else 补贴 end)
else 0 end)