This content has been marked as final. Show 4 replies
order by to_date("months",'MON-YYYY')SY.
In one of your last request i wrote already, use th_char on dates only for displaying purposes.
In this case usr trunc instead
Furthermore the order by in the inner connect by view is needless.
SELECT to_char(mon."months", 'MON-YYYY'), COUNT (DECODE (e1.ename, 'RAVI', 1, DECODE (e1.ename, 'KIRAN', 1, NULL))) AS "num-review" FROM ( SELECT TRUNC (ADD_MONTHS (SYSDATE, LEVEL - 7), 'MM') "months" FROM DUAL CONNECT BY LEVEL <= 18 ) mon, (SELECT ename, hiredate, TRUNC (hiredate, 'MM') "Month" FROM emp) e1 WHERE mon."months" = e1."Month"(+) GROUP BY "months" order BY "months"
Just thinking if your decode doing the same thing?
SELECT DECODE (e1.ename, 'RAVI', 1, 'KIRAN', 1, NULL) FROM DUAL;
Thanks to all. my query is working.