Selecting distinct combinations

Viewed 92292

I have a table which has 2 fields (latitude, longitude) and many other fields. I want to select the distinct combinations of latitude and longitude from this table.

What would be the query for that?

5 Answers
SELECT COLUMN1,COLUMN2 
FROM TABLE_NAME 
GROUP BY COLUMN1,COLUMN2 -- This will fetch the unique combinations

-- During this kind of selection it is always better to give a where condition so that the results are filtered before grouping

Your Code:

SELECT Latitude, Longitude 
  FROM Coordinates
GROUP BY Latitude, Longitude  

SELECT DISTINCT BY ( latitude, longitude)

This will work.

Related