1

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

user15397083
  • 51
  • 1
  • 5
  • 1
    What should be the desired recordset if c2 or c3 has a different value in each row? Lets say on first row c2='A' and c3=1 and in second row c2='A' and c3='2' than how can you get distinct record? you can find multiple distinct clauses answer here: https://stackoverflow.com/questions/42505531/multiple-distinct-on-clauses-in-postgresql – Ankit Mar 01 '22 at 06:34
  • 1
    Could you provide some sample data and expect results? – D-Shih Mar 01 '22 at 06:39
  • 1
    `distinct` is not a function. It is required to follow the SELECT keyword and always applies to all columns in the SELECT list. –  Mar 01 '22 at 06:49

1 Answers1

0

You simply can use distrinct on

SELECT DISTINCT ON (c2, c3) *
FROM YOURTABLENAME