DECLARE
st_month NUMBER(2) := 1;
no_o_emp NUMBER(3);
BEGIN
dbms_output.Put_line(Rpad('Month No', 20)
||Rpad('Month Name', 20)
|| 'Number of Employees');
dbms_output.Put_line('-------------------------------------------------------------');
FOR month IN 1 .. 12 LOOP
SELECT Count(*)
INTO no_o_emp
FROM employees
WHERE To_char(hire_date, 'mm') = month;
dbms_output.Put_line(Rpad(To_char(month, '00'), 20)
||Rpad(To_char(To_date(month, 'MM'), 'MONTH'), 20)
|| To_char(no_o_emp, '999'));
END LOOP;
END;
/
Sample Output:
SQL> /
Month No Month Name Number of Employees
-----------------------------------------------------------
01 JANUARY 14
02 FEBRUARY 13
03 MARCH 17
04 APRIL 7
05 MAY 6
06 JUNE 11
07 JULY 7
08 AUGUST 9
09 SEPTEMBER 5
10 OCTOBER 6
11 NOVEMBER 5
12 DECEMBER 7
PL/SQL procedure successfully completed.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer