Aggregate Function on Uniqueidentifier (GUID)

后端 未结 5 1388
日久生厌
日久生厌 2021-02-02 05:41

Let\'s say I have the following table:

category | guid
---------+-----------------------
   A     | 5BC2...
   A     | 6A1C...
   B     | 92A2...
5条回答
  •  既然无缘
    2021-02-02 06:21

    Assuming you're using SQL Server 2005 or later:

    ;with Numbered as (
         select category,guid,ROW_NUMBER() OVER (PARTITION BY category ORDER BY guid) rn
         from myTable
    )
    select * from Numbered where rn=1
    

提交回复
热议问题