Home » SQL & PL/SQL » SQL & PL/SQL » Eliminating the duplicate records
Eliminating the duplicate records [message #270418] Wed, 26 September 2007 18:34 Go to next message
decci_7
Messages: 68
Registered: March 2006
Member
Hi ..

I have the below recordset.

Quote:

Name Line Option
-----------------
ABC 1 Y
ABC 2 N
ABC 3 Y
XYZ 1 Y
XYZ 2 N



Now I need to get the resultset using a SQL statement, which will ftech me the result as the maximum Line number for that particular Name. In this case it should be:

Quote:

Name Line Option
-----------------
ABC 3 Y
XYZ 2 N



How can I achieve that. What kind of SQL can i use to produce this result.
Re: Eliminating the duplicate records [message #270420 is a reply to message #270418] Wed, 26 September 2007 18:56 Go to previous message
decci_7
Messages: 68
Registered: March 2006
Member
Got it ...

I used the wrong Join ... This one solves the problem.

select * from tablename a
where line = (select max(line) from tablename where name = a.name)
Previous Topic: Exception control flow
Next Topic: RDB7 Equivalent function of LEN(), or any way
Goto Forum:
  


Current Time: Sun Dec 11 00:34:07 CST 2016

Total time taken to generate the page: 0.13180 seconds