Home » SQL & PL/SQL » SQL & PL/SQL » How to find total no of employee and no of employee in given years
How to find total no of employee and no of employee in given years [message #605053] Tue, 07 January 2014 03:55 Go to next message
aaditya321
Messages: 225
Registered: January 2014
Location: Delhi
Senior Member
Total 1981 1982 1983 1984 1986
----------------------------------------
14 3 2 4 3 2


Re: How to find total no of employee and no of employee in given years [message #605057 is a reply to message #605053] Tue, 07 January 2014 04:09 Go to previous messageGo to next message
dariyoosh
Messages: 538
Registered: March 2009
Location: France
Senior Member
count
Re: How to find total no of employee and no of employee in given years [message #605067 is a reply to message #605053] Tue, 07 January 2014 04:32 Go to previous messageGo to next message
pablolee
Messages: 2882
Registered: May 2007
Location: Scotland
Senior Member
Hi, welcome to OraFaq.
This is not how to ask a question. Why should people give up their spare time for free to try to decipher your vague question?
Read the forum guidelines please.
Re: How to find total no of employee and no of employee in given years [message #605069 is a reply to message #605053] Tue, 07 January 2014 04:36 Go to previous messageGo to next message
Michel Cadot
Messages: 68641
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

SQL> select count(*) total,
  2         count(decode(extract(year from hiredate), 1981, empno)) "1981",
  3         count(decode(extract(year from hiredate), 1982, empno)) "1982",
  4         count(decode(extract(year from hiredate), 1983, empno)) "1983",
  5         count(decode(extract(year from hiredate), 1984, empno)) "1984",
  6         count(decode(extract(year from hiredate), 1986, empno)) "1986"
  7  from emp;
     TOTAL       1981       1982       1983       1984       1986
---------- ---------- ---------- ---------- ---------- ----------
        14         10          1          0          0          0
Re: How to find total no of employee and no of employee in given years [message #605422 is a reply to message #605069] Thu, 09 January 2014 04:24 Go to previous messageGo to next message
aaditya321
Messages: 225
Registered: January 2014
Location: Delhi
Senior Member
Thank you Michel Cadot, please convert your code in decode statement to case statement, I wanna to case statement method, if possible to solve then please help me.

Re: How to find total no of employee and no of employee in given years [message #605423 is a reply to message #605422] Thu, 09 January 2014 04:32 Go to previous messageGo to next message
Michel Cadot
Messages: 68641
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

What prevent you from doing it by yourself?

[Updated on: Thu, 09 January 2014 04:32]

Report message to a moderator

Re: How to find total no of employee and no of employee in given years [message #605426 is a reply to message #605423] Thu, 09 January 2014 04:40 Go to previous messageGo to next message
pablolee
Messages: 2882
Registered: May 2007
Location: Scotland
Senior Member
Michel Cadot wrote on Thu, 09 January 2014 10:32

What prevent you from doing it by yourself?


Don't ask questions Michel, just do the boy's homework for him. Chop Chop!
Re: How to find total no of employee and no of employee in given years [message #605518 is a reply to message #605423] Fri, 10 January 2014 04:11 Go to previous messageGo to next message
aaditya321
Messages: 225
Registered: January 2014
Location: Delhi
Senior Member
Hi Michel, Actually I want to work over sql tuning such as you know performance by decode is less than case statement so please help me.
Re: How to find total no of employee and no of employee in given years [message #605519 is a reply to message #605518] Fri, 10 January 2014 04:14 Go to previous message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
1) I seriously doubt you'd notice a performance difference.
2) Are you really saying you can't convert those decodes to case statements? Why not? Do you not understand the decode syntax or case syntax? Both are documented and that decode is as simple as it gets. So give it a try and if you get stuck post what you tried and we'll point out where you're going wrong.
Previous Topic: User who executed the Job
Next Topic: i wanto to return One single row into column.
Goto Forum:
  


Current Time: Fri Apr 19 09:01:14 CDT 2024