Postgresql databse with duplicate rows keep only the rows with true -


i've got 3 columns: groupid id yes/no/1

the database consists of rows duplicate values group (same group) want remove duplicate groups , have uniek group values. want keep te duplicate rows yes , remove rest.

so: if have 100 rows groupid 502 , there 400 no's, 50 "1", , 50 yes want have 1 row groupid 502 , should yes.

please help

use distinct on remove duplicate rows.

select distinct on (groupid) groupid, column_3 table_name column_3 'yes'; 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -