oracle里面
SELECT
企业名称,
类别,
ROW_NUMBER() OVER(PARTITION BY 类别 ORDER BY 类别,企业名称) AS 序号
from (
select 'A企业' as 企业名称,'服务类型2' as 类别 from dual
union all
select 'b企业' as 企业名称,'服务类型2' as 类别 from dual
union all
select 'BB企业' as 企业名称,'其他' as 类别 from dual
union all
select 'CC企业' as 企业名称,'其他' as 类别 from dual
union all
select 'dd企业' as 企业名称,'其他' as 类别 from dual
)