Answered Questions

  • Create a query that will display the total number of employees and of that total the number who were hired in 1980, 1981, 1982, and 1983. Give appropriate column headings.

    Star Read Best Answer

    Editorial / Best Answer

    letsconverse  

    • Member Since Sep-2009 | Sep 21st, 2009


    This one is better I guess:

    query:

    SELECT ((count(DECODE(to_char(hire_date,'YYYY'), 1995, 'c1')) )+(count(DECODE(to_char(hire_date,'YYYY'), 1996, 'c2')))+(count(DECODE(to_char(hire_date,'YYYY'), 1997, 'c3')))+(count(DECODE(to_char(hire_date,'YYYY'), 1998, 'c4')))) as TOTAL,
    count(DECODE(to_char(hire_date,'YYYY'), 1995, 'c1')) "1995",
    count(DECODE(to_char(hire_date,'YYYY'), 1996, 'c2')) "1996",
    count(DECODE(to_char(hire_date,'YYYY'), 1997, 'c3')) "1997",
    count(DECODE(to_char(hire_date,'YYYY'), 1998, 'c4')) "1998"
    FROM employees;

    Results for the above query is like:

         TOTAL       1995       1996       1997       1998
      ----------   ----------   ----------  ----------  ----------
              65             4            10           28           23

    Revert if you have a question. I'll try.
    NOTE: You may want to change the spl characters and the years based on your requiremnet.

    Thanks

    serine

    • Aug 26th, 2016

    Why did we use c1?

    ashwini

    • Jun 22nd, 2015

    Can anybody tell me how to get the count of the test cases that was run by a person?