oracle sql

Hello experts,
I have a table with data, from which I need to delete records keeping only the latest. here is how the table looks like

column1                               column2 (timestamp column)

abc                                         2014/11/22 08:08:38
abc                                         2015/03/06 06:10:39
abc                                         2015/03/06 08:10:39
.
.
def                                         2015/03/06 06:10:39
def                                         2015/03/06 08:10:39
def                                         2015/03/06 10:10:39

I want to keep records which have the latest time stamp like

abc                                        2015/03/06 08:10:39
def                                         2015/03/06 10:10:39

deleting the rest of the data. how can I do this in a query.
smaligAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

slightwv (䄆 Netminder) Commented:
select column1, column2 from(
select column1, column2, row_number() over(partition by column1 order by column2 desc) rn
from some_table
)
where rn=1
/
0
Mike EghtebasDatabase and Application DeveloperCommented:
Using the good solution from lightvw,

Delete from(
select column1, column2, row_number() over(partition by column1 order by column2 desc) rn
from some_table
)
where rn>1

Open in new window

0
slightwv (䄆 Netminder) Commented:
I don't believe that syntax works in Oracle...
0
slightwv (䄆 Netminder) Commented:
If you really want to delete the rows, something like:

delete from some_table where rowid in (
select row_to_delete from(
 select rowid row_to_delete, row_number() over(partition by column1 order by column2 desc) rn
 from some_table
 )
 where rn>1
)
/
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
smaligAuthor Commented:
thanks a lot slightwv. it worked
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.