select top 5 Id,[Type] from A where [Type] =0 union all select top 5 Id,[Type] from A where [Type] =1
用ROW_NUMBER ,你的代码少了排序列啊。不然TOP 5 就是随机取的了 select * from (select * ,row_number()over(partition by type order by colname) asn from A) as t where t.n<=5
34,576
社区成员
254,587
社区内容
加载中
试试用AI创作助手写篇文章吧