Selecting distinct 2 columns combination in mysql

前端 未结 6 1645
日久生厌
日久生厌 2020-12-03 03:13

I have a mysql table that looks like this:

1   value1    value2    3534
2   value1    value1    8456
3   value1    value2    3566
4   value1    value3    734         


        
6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-03 03:31

    This query makes sure that the combination of column1 and column2 is unique, while selecting the minimum value of column three

    SELECT col1, col2, MIN(col3)
    FROM yourTable
    GROUP BY col1, col2
    

提交回复
热议问题