SQL: Filter rows with max value

前端 未结 3 1140
一整个雨季
一整个雨季 2020-12-21 00:45

This is my table structure:

File    |   Version     |   Function
1       |   1           |   1
1       |   2           |   1
1       |   3           |   1
1          


        
3条回答
  •  萌比男神i
    2020-12-21 01:42

    In SQLite 3.7.11 or later, when you use MAX, the other values are guaranteed to come from the row with the largest value:

    SELECT File,
           MAX(Version) AS Version,
           Function
    FROM MyTable
    GROUP BY File
    

提交回复
热议问题