I have a table Person (id, name, city).
I want to return the records of persons with only one person from each city (city should be unique).
For example, if there are 10 records out of which 3 have city = 'Mumbai', other 3 have city = 'New York' and remaining 4 have city = 'Chicago', then I want to return 3 records (one with each city).
I tried various things including DISTINCT, ROWNUM, but not getting the desired result.
Can anyone please tell me how can this be achieved?
Try this:-