469,326 Members | 1,616 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,326 developers. It's quick & easy.

SELECT query to find max

kiss07
99
Hi,

i have a table emp:

empid
ename
deptid
joined_date
are the columns.

empid ename dept joined-date
------------------------------------------------------------------------------
101 arun cd2 12-APRIL-2007.

102 kumar mec 30-APRIL-2007.

103 DEBAS cs3 13-APRIL- 2007.

104 MUKIL HR 11-MARCH-2007.

109 DEAR ER4 11-APRIL- 2007.

900 SATHYA PER 30-JAN-2007.

303 KING FORCE 22-APRIL-2007.

i want to select april month maximum employees are joined.


expecting output:

month count
------- ----------
APRIL 5

PLS hepl anybody..

Arunkumar..
May 5 '07 #1
2 2560
frozenmist
179 Expert 100+
Hi,

i have a table emp:

empid
ename
deptid
joined_date
are the columns.

empid ename dept joined-date
------------------------------------------------------------------------------
101 arun cd2 12-APRIL-2007.

102 kumar mec 30-APRIL-2007.

103 DEBAS cs3 13-APRIL- 2007.

104 MUKIL HR 11-MARCH-2007.

109 DEAR ER4 11-APRIL- 2007.

900 SATHYA PER 30-JAN-2007.

303 KING FORCE 22-APRIL-2007.

i want to select april month maximum employees are joined.


expecting output:

month count
------- ----------
APRIL 5

PLS hepl anybody..

Arunkumar..
Expand|Select|Wrap|Line Numbers
  1.  
  2. select mon as  " MONTH" , cnt as "COUNT"  from 
  3.  
  4. (select count(*) cnt,to_char(joined_date,'MONTH') mon 
  5. from emp 
  6. group by to_char(joined_date,'MONTH') 
  7. order by cnt desc ) 
  8.  
  9. where rownum=1
  10.  
hope this answers ur question.
Cheers
May 5 '07 #2
debasisdas
8,127 Expert 4TB
HI Arun

If u want to find out in which month maximum employees joined the company the below query in the previous will do the trick for u.
May 5 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

21 posts views Thread by John Fabiani | last post: by
4 posts views Thread by Denis St-Michel | last post: by
2 posts views Thread by phpuser32423 | last post: by
3 posts views Thread by Tcs | last post: by
5 posts views Thread by parwal.sandeep | last post: by
22 posts views Thread by MP | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Gurmeet2796 | last post: by
reply views Thread by mdpf | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.