Home » SQL & PL/SQL » SQL & PL/SQL » MAX .. Group By
MAX .. Group By [message #271432] Mon, 01 October 2007 12:02 Go to next message
ada26
Messages: 15
Registered: September 2007
Location: cleveland
Junior Member
I have here complicated data :

ID NAME LOGIN HIREDATE ADDRESS
1 ANA ABC 2/15/2006 OH
2 ANA 5/18/199 CA
3 ANA ABC 9/15/2004 CA
4 LYN LLL 3/15/199 VA

i need to get the MAX(ID)of each employee having same name.

ID NAME LOGIN HIREDATE ADDRESS
3 ANA ABC 9/15/2004 CA
4 LYN LLL 3/15/199 VA

-------
select max(id), name, login, hiredate, address
from emp
group by name, login, hiredate, address

does not work!



Re: MAX .. Group By [message #271433 is a reply to message #271432] Mon, 01 October 2007 12:04 Go to previous messageGo to next message
BlackSwan
Messages: 25050
Registered: January 2009
Location: SoCal
Senior Member
>does not work!
My car does not work.
Tell me how to make my car work, please.

Please read & FOLLOW posting guidelines as stated in the #1 STICKY post found at the very top of this forum.
Re: MAX .. Group By [message #271438 is a reply to message #271432] Mon, 01 October 2007 12:10 Go to previous messageGo to next message
ada26
Messages: 15
Registered: September 2007
Location: cleveland
Junior Member
this query gives me this:

select max(id), name, login, hiredate, address
from emp
group by name, login, hiredate, address

ID NAME LOGIN HIREDATE ADDRESS
2 ANA 5/18/199 CA
3 ANA ABC 9/15/2004 CA
4 LYN LLL 3/15/199 VA



Re: MAX .. Group By [message #271439 is a reply to message #271432] Mon, 01 October 2007 12:16 Go to previous messageGo to next message
Michel Cadot
Messages: 64153
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Please read and follow OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format. Use the "Preview Message" button.
Please always post your Oracle version (4 decimals).

But you don't write what you are asking.
I quote you: "i need to get the MAX(ID)of each employee having same name" and you grouped by "name, login, hiredate, address", this is not the same.
Do you understand?

Regards
Michel
Re: MAX .. Group By [message #271508 is a reply to message #271432] Mon, 01 October 2007 15:37 Go to previous message
S.Rajaram
Messages: 1027
Registered: October 2006
Location: United Kingdom
Senior Member
http://forums.oracle.com/forums/thread.jspa?messageID=2111593&#2111593
Previous Topic: ora00918
Next Topic: Insert from cursor
Goto Forum:
  


Current Time: Sun Dec 11 08:14:09 CST 2016

Total time taken to generate the page: 0.10512 seconds