473,327 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

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 2686
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

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

Similar topics

21
by: John Fabiani | last post by:
Hi, I'm a newbie and I'm attempting to learn howto create a select statement. When I use >>> string1='18 Tadlock Place' >>> cursor.execute("SELECT * FROM mytest where address = %s",string1) All...
4
by: Denis St-Michel | last post by:
Hello All, Hope some Guru will be able to help me with this. Let's take this example table A ------------------------------------------------------------------------------- id | ...
2
by: phpuser32423 | last post by:
Hi everyone Is it by any chance possible to use mysql and php to auto create the content for drop-down lists on forms by retrieving the values from a database? The reason i ask is that on a site...
10
by: serge | last post by:
Using "SELECT * " is a bad practice even when using a VIEW instead of a table? I have some stored procedures that are identical with the difference of one statement in the WHERE clause. If I...
3
by: Tcs | last post by:
My backend is DB2 on our AS/400. While I do HAVE DB2 PE for my PC, I haven't loaded it yet. I'm still using MS Access. And no, I don't believe this is an Access question. (But who knows? I...
23
by: Brian | last post by:
Hello All - I am wondering if anyone has any thoughts on which is better from a performance perspective: a nested Select statement or an Inner Join. For example, I could do either of the...
5
by: parwal.sandeep | last post by:
Hello grp! i'm using INNODB tables which are using frequently . if i fire a SELECT query which fetch major part of table it usually take 10-20 seconds to complete. in mean time if any UPDATE...
1
by: JC | last post by:
Hello, I am trying to change a select, find duplicates, query into a delete query. I want to get rid of the records in the main table "tblHurnsHistory." I changed the Find Duplicates query to...
22
by: MP | last post by:
vb6,ado,mdb,win2k i pass the sql string to the .Execute method on the open connection to Table_Name(const) db table fwiw (the connection opened via class wrapper:) msConnString = "Data Source="...
1
by: zafm86 | last post by:
Hi everyone! I'm sure my problem is pretty easy to solve but I've been working on it for a long and my my brain is not working correctly anymore. I'm working with an AS400 and I mhave to do an...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.