This should return only one records per ID. The query below will return the MIN() value for both the city and state using a GROUP BY id field. Since you have more than one ID and you only want to return one value, then this will only return the first record that meets the requirement.
select ID, min(city) city, min(state) state
from yourTable
group by ID
See SQL Fiddle with Demo
So this works the following way
YourTable
ID city state
1 efef dfdd
2 dwef sdfsd
1 fdds fsdfs
If we take the MIN() value of the city and state columns and GROUP BY id you result would be:
YourTable
ID city state
1 efef dfdd
2 dwef sdfsd
MIN() is going to return the lowest in the sequence. So since the city with the ID of 1 begins with e and e is before f then it will be selected. The GROUP BY combines all ID that match into a cluster.
Then if you wanted to exclude any record that had a duplicate id, then you could just change the query to:
select ID, min(city) city, min(state) state
from yourTable
group by ID
having min(city) = max(city)
and min(state) = max(state)
Edit:
You can also use:
select min(rowid) rowid, ID, city, state
from yourTable
group by ID
or:
select *
from yourTable t1
inner join
(
select min(rowid) row_id, ID
from yourTable
group by ID
) t2
on t1.rowid = t2.row_id
and t1.id = t2.id
id=1you want to retrieve?ORDER BY a_column