Editorial / Best Answer
letsconverse
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
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.
Editorial / Best Answer
letsconverseProfile Answers by letsconverse Questions by letsconverse
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
Related Answered Questions
Related Open Questions