update test m set pkum = (case u.cd when '2' then pkum - u.janyear else pkum end),
rkum = (case u.cd when '1' then rkum - u.janyear else rkum end),
dt = (case u.cd when '2' then dt - janmon else dt end),
ct = (case u.cd when '1' then ct - janmon else ct end)
from ( select s.member_mid, blsbcode, mbacode1, cd ,
sum(case when mbcheck <> '' and (substr(blaccode,1,1)='b' or substr(blaccode,1,1)='p')
then case cd when '1' then coalesce(dt,0)
else coalesce(dt,0) end
else 0 end)::numeric janmon,
sum(case when mbcheck <> '' and (substr(blaccode,1,1)='b' or substr(blaccode,1,1)='p')
then case cd when '1' then coalesce(pkum,0)
else coalesce(rtkum,0) end
else 0 end )::numeric janyear
from test s left outer join accset c
on s.member_mid= c.member_mid
and s.blaccode = c.mbacode
where s.member_mid='test'
and s.blsbcode='00'
and mbcheck <> ''
and coalesce(c.mbacode1,'') <> ''
group by s.member_mid, blsbcode, mbacode1, cd ) u
where m.member_mid = u.member_mid
and m.blsbcode = u.blsbcode
and m.blaccode = u.mbacode1
'program' 카테고리의 다른 글
pgsql 암호화 복호화 (0) | 2015.06.26 |
---|---|
이미지 빠지지 않는 QuickReport 용 TQRImage 호환 (0) | 2015.06.18 |
Win7 32bit 4기가이상 램 패치 (0) | 2014.10.27 |
Delphi XE2 Unit Scope tables (0) | 2014.06.12 |
[Delphi] Delphi Xe3 + Indy 10 (0) | 2014.01.10 |