불필요하게 1번씩 더 access되어 있는 형태군요...;
아래 참고하여 정리하시길...;
SELECT
a.staf -- 담당자
, SUM(a.tot_amnt), -- 6월성과금 합계
CASE WHEN a.team<>'2050'
THEN
CASE WHEN SUM(a.tot_amnt) < 5000000 THEN FLOOR(SUM(a.tot_amnt)*0.06)
WHEN SUM(a.tot_amnt) BETWEEN 5000000 AND 9999999 THEN FLOOR(SUM(a.tot_amnt)*0.08)
WHEN SUM(a.tot_amnt) BETWEEN 10000000 AND 12999999 THEN FLOOR(SUM(a.tot_amnt)*0.1)
WHEN SUM(a.tot_amnt) BETWEEN 13000000 AND 15999999 THEN FLOOR(SUM(a.tot_amnt)*0.11)
WHEN SUM(a.tot_amnt) BETWEEN 16000000 AND 17999999 THEN FLOOR(SUM(a.tot_amnt)*0.12)
WHEN SUM(a.tot_amnt) BETWEEN 18000000 AND 19999999 THEN FLOOR(SUM(a.tot_amnt)*0.13)
WHEN SUM(a.recv_tot_amnt) BETWEEN 20000000 AND 21999999 THEN FLOOR(SUM(a.recv_tot_amnt)*0.14)
ELSE SUM(FLOOR(SUM(a.recv_tot_amnt)*0.15))
END
WHEN a.team='2050' THEN FLOOR(SUM(a.tot_amnt * DECODE(b.mbs_ysno, 'Y', 0.1, 0.13)))
ELSE FLOOR(SUM(a.tot_amnt)*0.06)
END BB
FROM a, b
WHERE a.ID = b.ID
AND a.numb = b.numb
AND a.seq = b.seq
AND TO_CHAR(DATE, 'YYYYMM') = '200706'
AND b.TYPE = '2'
AND staf <> '103012'
AND b.use_ysno = ' '
GROUP BY a.staf, a.team
건승하시길...수고하세요~~