Home > database >  SQL how to select distinct several columns
SQL how to select distinct several columns

Time:03-01

lets say there are several columns (c1, c2, c3, c4) It's okay for each column to be appeared several times, but I want to select all the columns with several columns distinct.

I want SELECT c1, DISTINCT(c2, c3), c4 something like this but it doesnt work, and GROUP BY doesnt work as well.

somebody help me please

CodePudding user response:

You simply can use distrinct on

SELECT DISTINCT ON (c2, c3) *
FROM YOURTABLENAME
  • Related