Query:
SELECT DISTINCT ON (geom_line),gid
FROM edge_table;
I have a edge table which contains duplicates and I want to remove duplicate edges keeping one of them, but the syntax itself is wrong?
Query:
SELECT DISTINCT ON (geom_line),gid
FROM edge_table;
I have a edge table which contains duplicates and I want to remove duplicate edges keeping one of them, but the syntax itself is wrong?
Copyright © 2021 Jogjafile Inc.
The comma is the problem.
If you want
geom_lineincluded in the result, useElse use
But if your objective is just to remove duplicates, I'd say that you should use
DISTINCTguarantees uniqueness over the whole result set, whileDISTINCT ONguarantees uniqueness over the expression in parentheses. If there are several rows where the expression in parentheses is identical, one of these rows is picked. If you have anORDER BYclause, the first row will be picked.DISTINCT a, bis the same asDISTINCT ON (a, b) a, b.