Skip to content
Advertisement

Get last row per group in SQL

I have the data below, and i want to get the last row per desc

enter image description here

the result should be like this:

enter image description here

how can i do it in SQL, please note that database is oracle.

Advertisement

Answer

You can get the expected result with the following query:

select * from tbl1
where id1 in (select max(id1) from tbl1 group by desc1);
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement