Problem with DISTINCT when adding the ID column


I have the following query;

SELECT DISTINCT coordx,nis,nic,ct,medidor,coordy,comentario FROM nis_cap

This query brings me 544 records;

The problem is that if I modify the query to add the ID, DISTINCT does not work as I expect;

-- Agrege la columna id luego de coordx
SELECT DISTINCT coordx,id,nis,nic,ct,medidor,coordy,comentario FROM nis_cap

This brings me all the records that exist in the table and I only need the coordinates x to be unique.

The idea is to bring the records that have unique coordinates, imagining that these data are "buildings" and in a "building" there are several apartments, so the apartments of a building inherit the coordinates and these will be duplicated in the base of data.

I have an interface to modify "The buildings" but the app is loaded too much by having many points in the same coordinates.

Placing the query without the primary key everything works fine, until I add it and the idea of adding the primary key is to modify the data by its primary key

asked by Albert Hidalgo 13.10.2018 в 16:27

0 answers