sql server select first row from a group

前端 未结 2 1240
遥遥无期
遥遥无期 2020-11-30 05:33

I have table like this:

a          b
1          23
1          2
1          7
2          9
2          11

I want to select the first row(orde

2条回答
  •  有刺的猬
    2020-11-30 06:02

    If as you indicated, order doesn't matter, any aggregate function on b would be sufficient.

    Example Using MIN

    SELECT a, b = MIN(b)
    FROM   YourTable
    GROUP BY
           a
    

提交回复
热议问题