Friday, January 22, 2021

Total employee count in years wise in oracle sql


    SELECT COUNT (*),

          COUNT (DECODE (TO_CHAR (hire_date, 'RRRR'), '1980', employee_id)) "1980",

         COUNT (DECODE (TO_CHAR (hire_date, 'RRRR'), '1981', employee_id)) "1981",

         COUNT (DECODE (TO_CHAR (hire_date, 'RRRR'), '1982', employee_id)) "1982",

         COUNT (DECODE (TO_CHAR (hire_date, 'RRRR'), '1983', employee_id)) "1983"

    FROM employees


  COUNT(*)       1980       1981       1982       1983

---------- ---------- ---------- ---------- ----------

       107          0          0          0          0


    SELECT COUNT (*),

          COUNT (DECODE (TO_CHAR (hire_date, 'RR'), '02', employee_id)) "02",

          COUNT (DECODE (TO_CHAR (hire_date, 'RR'), '03', employee_id)) "03",

          COUNT (DECODE (TO_CHAR (hire_date, 'RR'), '04', employee_id)) "04",

         COUNT (DECODE (TO_CHAR (hire_date, 'RR'), '05', employee_id)) "05"

    FROM employees

  COUNT(*)         02         03         04         05

---------- ---------- ---------- ---------- ----------

       107          7          6         10         29

No comments:

Post a Comment

To generate a PDF using JavaScript in Oracle APEX from a collection

  To generate a PDF using JavaScript in Oracle APEX from a collection, you can follow these steps: 1. Create a button or link on your APEX p...