select a.*
from 产品表 AS a,
(
select id,rn=ROW_NUMBER() over(partition by [Type] order by ProductName)
from 产品表
where ProductName like '%香蕉%'
) AS b
where a.id=b.id and b.rn<=10
declare @A TABLE(type1 int,name varchar(2))
insert into @A
select 1,'a'
union
select 1,'b'
union
select 1,'c'
union
select 1,'d'
union
select 2,'b'
union
select 3,'b'
union
select 2,'d'
union
select 3,'d'
select * from (
select ROW_NUMBER() over(partition by type1 order by type1) id,* from @A
)t
where id<=10
declare @A TABLE(type1 int,name varchar(2))
insert into @A
select 1,'a'
union
select 1,'b'
union
select 1,'c'
union
select 1,'d'
union
select 2,'b'
union
select 3,'b'
union
select 2,'d'
union
select 3,'d'
select ROW_NUMBER() over(partition by type1 order by type1),* from @A
order by type1,name