update payroll.pbpaymst_jj b
set b.s11000 = (
(case
when b.px7000 = 1
then ( select family1 from payroll.pwtaxtbl where appym = (select ifnull(max(appym), '200701') from payroll.pwtaxtbl) and framt < b.px3000 and toamt >= b.px3000)
when b.px7000 = 2
then ( select family2 from payroll.pwtaxtbl where appym = (select ifnull(max(appym), '200701') from payroll.pwtaxtbl) and framt < b.px3000 and toamt >= b.px3000)
when b.px7000 = 3 and b.px6000 > 1
then ( select family3b from payroll.pwtaxtbl where appym = (select ifnull(max(appym), '200701') from payroll.pwtaxtbl) and framt < b.px3000 and toamt >= b.px3000)
when b.px7000 = 3 and b.px6000 < 2
then ( select family3 from payroll.pwtaxtbl where appym = (select ifnull(max(appym), '200701') from payroll.pwtaxtbl) and framt < b.px3000 and toamt >= b.px3000)
when b.px7000 = 4 and b.px6000 > 1
then ( select family4b from payroll.pwtaxtbl where appym = (select ifnull(max(appym), '200701') from payroll.pwtaxtbl) and framt < b.px3000 and toamt >= b.px3000)
when b.px7000 = 4 and b.px6000 < 2
then ( select family4 from payroll.pwtaxtbl where appym = (select ifnull(max(appym), '200701') from payroll.pwtaxtbl) and framt < b.px3000 and toamt >= b.px3000)
when b.px7000 = 5 and b.px6000 > 1
then ( select family5b from payroll.pwtaxtbl where appym = (select ifnull(max(appym), '200701') from payroll.pwtaxtbl) and framt < b.px3000 and toamt >= b.px3000)
when b.px7000 = 5 and b.px6000 < 2
then ( select family5 from payroll.pwtaxtbl where appym = (select ifnull(max(appym), '200701') from payroll.pwtaxtbl) and framt < b.px3000 and toamt >= b.px3000)
when b.px7000 = 6 and b.px6000 > 1
then ( select family6b from payroll.pwtaxtbl where appym = (select ifnull(max(appym), '200701') from payroll.pwtaxtbl) and framt < b.px3000 and toamt >= b.px3000)
when b.px7000 = 6 and b.px6000 < 2
then ( select family6 from payroll.pwtaxtbl where appym = (select ifnull(max(appym), '200701') from payroll.pwtaxtbl) and framt < b.px3000 and toamt >= b.px3000)
when b.px7000 = 7 and b.px6000 > 1
then ( select family7b from payroll.pwtaxtbl where appym = (select ifnull(max(appym), '200701') from payroll.pwtaxtbl) and framt < b.px3000 and toamt >= b.px3000)
when b.px7000 = 7 and b.px6000 < 2
then ( select family7 from payroll.pwtaxtbl where appym = (select ifnull(max(appym), '200701') from payroll.pwtaxtbl) and framt < b.px3000 and toamt >= b.px3000)
when b.px7000 = 8 and b.px6000 > 1
then ( select family8b from payroll.pwtaxtbl where appym = (select ifnull(max(appym), '200701') from payroll.pwtaxtbl) and framt < b.px3000 and toamt >= b.px3000)
when b.px7000 = 8 and b.px6000 < 2
then ( select family8 from payroll.pwtaxtbl where appym = (select ifnull(max(appym), '200701') from payroll.pwtaxtbl) and framt < b.px3000 and toamt >= b.px3000)
when b.px7000 = 9 and b.px6000 > 1
then ( select family9b from payroll.pwtaxtbl where appym = (select ifnull(max(appym), '200701') from payroll.pwtaxtbl) and framt < b.px3000 and toamt >= b.px3000)
when b.px7000 = 9 and b.px6000 < 2
then ( select family9 from payroll.pwtaxtbl where appym = (select ifnull(max(appym), '200701') from payroll.pwtaxtbl) and framt < b.px3000 and toamt >= b.px3000)
when b.px7000 = 10 and b.px6000 > 1
then ( select family10b from payroll.pwtaxtbl where appym = (select ifnull(max(appym), '200701') from payroll.pwtaxtbl) and framt < b.px3000 and toamt >= b.px3000)
when b.px7000 = 10 and b.px6000 < 2
then ( select family10 from payroll.pwtaxtbl where appym = (select ifnull(max(appym), '200701') from payroll.pwtaxtbl) and framt < b.px3000 and toamt >= b.px3000)
when b.px7000 = 11 and b.px6000 > 1
then ( select family11b from payroll.pwtaxtbl where appym = (select ifnull(max(appym), '200701') from payroll.pwtaxtbl) and framt < b.px3000 and toamt >= b.px3000)
when b.px7000 = 11 and b.px6000 < 2
then ( select family11 from payroll.pwtaxtbl where appym = (select ifnull(max(appym), '200701') from payroll.pwtaxtbl) and framt < b.px3000 and toamt >= b.px3000)
when b.px7000 > 11 and b.px6000 > 1
then ( select family3b from payroll.pwtaxtbl where appym = (select ifnull(max(appym), '200701') from payroll.pwtaxtbl) and framt < b.px3000 and toamt >= b.px3000)
when b.px7000 > 11 and b.px6000 < 2
then ( select family3 from payroll.pwtaxtbl where appym = (select ifnull(max(appym), '200701') from payroll.pwtaxtbl) and framt < b.px3000 and toamt >= b.px3000)
else '1'
end)
)
where b.appdt = '200808'
and b.paydiv = 'S'
and b.px3000 >= 800000
조건이 좀복잡해서 이런식으로 쿼리를 만들엇는데요
winsql에서 아래와같은 에러를 뱉어내는데요....
Error: SQL0901 - SQL system error. (State:S1000, Native Code: FFFFFC7B)
원인이 무엇인지...ㅠㅠ 이거때문에 지금 1주일째고생하고있음..ㅠㅠ 살려주십시오...
|