postgresql - Remove the repetitive row by checking different column -


i have data sample such below :

set of data

how can postgresql eliminate duplicate row check column1 , column2 @ different row ? doing normal comparison still unlucky @ time. hope may share idea.

select d1.* distance d1 not exists (select 1                   distance d2                   d1."from" = d2."to"                     , d1."to" = d2."from"                     , d2."from" < d2."to"                  ); 

if there “duplicate”, query pick row "from" < "to".


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -