SELECT WEEKS, SUM(DECODE(D,'1', DAYNUM)) AS SUN, SUM(DECODE(D,'2', DAYNUM)) AS MON, SUM(DECODE(D,'3', DAYNUM)) AS TUE, SUM(DECODE(D,'4', DAYNUM)) AS WED, SUM(DECODE(D,'5', DAYNUM)) AS THU, SUM(DECODE(D,'6', DAYNUM)) AS FRI, SUM(DECODE(D,'7', DAYNUM)) AS SAT FROM ( SELECT ROWNUM AS DAYNUM, TO_CHAR(TO_DATE(B.YYMM||LPAD(ROWNUM,2,'0'),'YYYYMMDD'), 'D') AS D, CAST(TO_CHAR(TO_DATE(B.YYMM||LPAD(ROWNUM,..