可以先在SQL里分个组,如sql server 参考
with a as(
select 1 as 订单号,11 品名,'组件11' as 品名2,'2023-03-08' 计划发货日期,10 发货数量,'2023-03-14' as 发货日期
union all
select 1 as 订单号,11 品名,'组件11' as 品名2,'2023-03-08' 计划发货日期,10 发货数量,'2023-03-15' as 发货日期
union all
select 1 as 订单号,11 品名,'组件11' as 品名2,'2023-03-08' 计划发货日期,8 发货数量,'2023-03-18' as 发货日期
union all
select 1 as 订单号,11 品名,'组件11' as 品名2,'2023-03-08' 计划发货日期,8 发货数量,'2023-03-20' as 发货日期
union all
select 1 as 订单号,22 品名,'组件22' as 品名2,'2023-03-08' 计划发货日期,2 发货数量,'2023-03-20' as 发货日期
union all
select 2 as 订单号,22 品名,'组件22' as 品名2,'2023-03-08' 计划发货日期,2 发货数量,'2023-03-20' as 发货日期
)
select *,
ROW_NUMBER()over( partition by 订单号,品名,品名2,发货数量 order by 发货日期) as xh,
DENSE_RANK()over( order by 订单号,品名,品名2,发货数量) as xh1
from a

再把序号1隐藏起来即可