I'm wondering why this query doesn't give me the expected (by me) result. I have a table like this, with many rows. For each city there is a unique geonameid. Each city could have it's version in different languages.
alternatenameId | geonameid | isoLanguage | alternateName | isPreferredName
1554355            5128581        en          Big Apple
1614284            5128581        en        New York City   
9138713            5128581        en          New York            1
This is the query (I limited to one city to make an example, but I'll extend to more cities):
SELECT geonameid, 
       alternateName, 
       MAX(isPreferredName) 
FROM alternatename_new 
WHERE geonameid=5128581 
AND isoLanguage = 'en' 
GROUP BY geonameid
This is the query result
 geonameid | alternateName | isPreferredName
  5128581     Big Apple            1
But i expect to have this
 geonameid | alternateName | isPreferredName
  5128581      New York            1
What I'm doing wrong?
 
     
     
     
    