2011년 6월 2일 목요일

퍼센트 구하기


SELECT rownum || '.' || DECODE(part_of_defect1, '희희', '기타', part_of_defect1) || ', ' || qty || ', ' || TRIM(TO_CHAR(pr, '990.99')) || '%' nm,
       qty c11n
FROM   (SELECT part_of_defect1,
               qty,
               ROUND(RATIO_TO_REPORT(qty) OVER() * 100, 2) pr
        FROM   (SELECT DECODE(part_of_defect1, '기능불량', '희희', null, '희희', part_of_defect1) part_of_defect1,
                       SUM(qty) qty
                FROM   (SELECT *
                        FROM   통계테이블
                        WHERE  1 = 1
                        AND    DEFECT_REASON = '외관불량'
                        AND    actual_return_date >= '20110101'
                        AND    actual_return_date <= '20110301'
                        --검색조건
                               )
                GROUP BY part_of_defect1 ) )

댓글 없음:

댓글 쓰기