sql server:
select [fd_xiangMuHao] 项目号,[fd_wuLiaoDaiMa] 物料代码,[fd_fuWuMiaoShu] 描述
from [dbo].[ekp_LXSQD] a inner join [dbo].[ekp_LXSQD_ZB2] b on a.fd_id = b.[fd_parent_id]
with a as (
SELECT 'f' A,'3123' B UNION ALL
SELECT 'f' A,'4213' B UNION ALL
SELECT 'f' A,'5124' B UNION ALL
SELECT 'g' A,'3421' B UNION ALL
SELECT 'g' A,'521' B
)
SELECT A,B,CONCAT(A,'-',RN) FROM (
select a.A,a.B,row_number() over(partition by a.A order by a.B) RN from a
) C
就是分组排序而已 网上一搜 太多了
去搜一下你这个数据库的开窗函数就解决了