Return all columns with distinct on multiple columns in SQL table

前端 未结 2 1428
梦毁少年i
梦毁少年i 2021-01-29 16:03

I have 5 columns in sql table and I need all the 5 columns as out put but with distinct operation on three columns

Need to return all the columns with distinct operation

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-29 16:42

    Can group by 3 but must use some type of aggregate function like min or max on the other two

    select col1, col2, col3, max(col4), min(col5) 
    from tbl 
    group by col1, col2, col3
    

提交回复
热议问题