Suppose I have a table as below in Oracle database
ID NAME SAVED_ON
_____________________________
10 APPLE 10-DEC-17 03.08.26.353000000 PM
15 MANGO 10-DEC-17 05.08.26.353000000 PM
17 APPLE 10-DEC-17 04.08.26.353000000 PM
19 APPLE 10-DEC-17 02.08.26.353000000 PM
23 MANGO 10-DEC-17 01.08.26.353000000 PM
My Requirement is :
I need all the distinct id's but taking the above table as example,
For Apple
we have 3
entries in the table and similarly for mango
we have 2
entries but I need a sql query
which will give the id
of the entry of the apple
and mango
which was saved at the last i.e maximum saved_on timing
.
i.e group by name and order by saved_on and final result should be id's with max(saved_on)
The ouput should come as Id
's- 15,17