GeekInterview.com
Series: Subject:
Question: 4 of 234

Matrix Query

Create a query to display the total number of employees, of that total, the number of employees hired in 1995, 1996, 1997, 1998. Create appropriate column heading from the employees table.
Asked by: enochnikoi | Member Since Mar-2011 | Asked on: Mar 9th, 2011

View all questions by enochnikoi   View all answers by enochnikoi

Showing Answers 1 - 2 of 2 Answers
mlodugu

Answered On : Apr 10th, 2011

View all answers by mlodugu

How about this?

SELECT SUM(sal) Total_sal, extract(year from hiredate) Yr
FROM scott.emp GROUP BY Rollup(extract(year from hiredate))

  
Login to rate this answer.
Prem_p

Answered On : Apr 28th, 2011

View all answers by Prem_p

SELECT count(e.empno) Emp_Count,to_char(e.hiredate,'YYYY') hired_On   
from empoyee e
where to_char(e.hiredate,'YYYY') in (1995, 1996, 1997, 1998)
group by rollup(to_char(e.hiredate,'YYYY')) 
order by 2

  
Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.