Postgres: Distinct but only for one column

后端 未结 4 1735
情深已故
情深已故 2020-12-02 07:08

I have a table on pgsql with names (having more than 1 mio. rows), but I have also many duplicates. I select 3 fields: id, name, metadata

4条回答
  •  庸人自扰
    2020-12-02 07:36

    To do a distinct on n columns:

    select distinct on (col1, col2) col1, col2, col3, col4 from names
    

提交回复
热议问题