Create a query that will display the total no.of employees and, of that total, the no.of employees hired in 1995,1996,1997, and 1998. create appropriate column headings.

Showing Answers 1 - 25 of 25 Answers

mano

  • Sep 27th, 2006
 

Hi ,

U can use with the help of Decode fn.

  Was this answer useful?  Yes

hafeez

  • Oct 4th, 2006
 

select count(*),to_char(hiredate,'yyyy') from emp  group by to_char(hiredate,'yyyy')

  Was this answer useful?  Yes

dustlove

  • Aug 22nd, 2007
 

Like this:
select count(*), count(decode(to_char(hire_date, 'yyyy'),'1995', 1, null)) y1995,
       count(decode(to_char(hire_date, 'yyyy'),'1996', 1, null)) y1996 from co_counter 

emraan

  • Dec 28th, 2009
 

select count(*)"Total Employees", count(decode(to_char(hiredate, 'yyyy'),1981,1)) "Year - 1981", count(decode(to_char(hiredate, 'yyyy'),1982,1)) "Year - 1982", count(decode(to_char(hiredate, 'yyyy'),1983,1)) "Year - 1983" from emp


kishorekumar522

  • Jul 19th, 2011
 

Two ways

Code
  1. SELECT COUNT(DECODE(TO_CHAR(hire_date, 'yyyy'),'1995', 1

  2. , NULL))   y1995,COUNT(DECODE(TO_CHAR(hire_date, 'yyyy'),'1996', 1, NULL))  y1996,COUNT(DECODE(TO_CHAR(hire_date, 'yyyy'),

  3. '1997', 1, NULL))

  4. y1997,COUNT(DECODE(TO_CHAR(hire_date, 'yyyy'),'1998',

  5. 1, NULL)) y1998 FROM employees;

  6.  

  7.  

  8. SELECT COUNT(*) AS tot,TO_CHAR(hire_date,'yyyy') FROM employees

  9. WHERE TO_CHAR(hire_date,'yyyy') IN ('1995','1996','1997','1998') GROUP BY TO_CHAR(hire_date,'yyyy') ORDER BY 2;

  Was this answer useful?  Yes

hussain

  • Jul 26th, 2011
 

select * from employees where hiredate =#1995,1996,1997,1998#;

  Was this answer useful?  Yes

The all queries are not correct the only correct query is
Select Name, Date from test where Date like '1995%'; lll ly for other dates too.

Code
  1. SELECT Name, DATE FROM test WHERE DATE LIKE '1995%';

Arjun Bansal

  • Oct 1st, 2011
 

select count(*)"Total Employees", count(decode(to_char(hiredate, 'yyyy'),1981,1)) "Year - 1981", count(decode(to_char(hiredate, 'yyyy'),1982,1)) "Year - 1982", count(decode(to_char(hiredate, 'yyyy'),1983,1)) "Year - 1983" from emp


  Was this answer useful?  Yes

Prashanth

  • Oct 10th, 2011
 

Exact query you required..... Try it out if you have any doubts.

Code
  1. SELECT count(*),to_char(hire_date,'yyyy') FROM employees WHERE to_char(hire_date,'yyyy') BETWEEN 1995 AND 1998 GROUP BY to_char(hire_date,'yyyy');

  Was this answer useful?  Yes

Give your answer:

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

 

Related Answered Questions

 

Related Open Questions