I have a table with 2 columns (id, name) with following values:
id    name
---   ---
 1    John
 2    John 
 3    Mary
 4    Mary
For values that are repeated in 'name', I only want to select those rows which have maximum value in 'id'. So my desired output is:
id    name
---   ---
 2    John
 4    Mary
I tried following instructions from this link: Fetch the row which has the Max value for a column but couldn't get it to work.
This is the query I'm using:
select 
    name, id 
from
    (select 
         name, max(id) over (partition by name) max_ID 
     from sometable) 
where 
    id = max_ID
But I'm getting this error:
Incorrect syntax near the keyword 'where'.
Any ideas what I'm doing wrong?
 
     
     
     
    