22,297
社区成员
发帖
与我相关
我的任务
分享
with tb(a) as(
select 'A0101' union all
select 'A0102' union all
select 'A0103' union all
select 'A0104' union all
select 'b0101' union all
select 'b0102' union all
select 'b0103' union all
select 'b0104' union all
select 'c0101' union all
select 'c0102' union all
select 'c0103' union all
select 'c0104' )
,tc as(
select ROW_NUMBER() over(partition by left(a,2)order by newid())number,* from tb)
select a from tc where number=1
--每次执行都不一样