sql - how to select one row from several rows with minimum value -


the question based on sql query select distinct row minimum value. consider table:

id  game   point 1    x      1 1    y      10 1    z      1 2    x      2 2    y      5 2    z      8 

using suggested answers mentioned question (select ids have minimum value in point column, grouped game) obtain

id  game   point     1    x      1 1    z      1 2    x      2   

the question how obtain answer single output each id. both outputs

id  game   point     1    x      1 2    x      2  

and

id  game   point     1    z      1 2    x      2  

are acceptable.

use row_number():

select t.* (select t.*,              row_number() on (partition id order point asc) seqnum       t      ) t seqnum = 1; 

Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -