???
这完全不同啊
--------------
这两个 改成 concat(item,item2)
-------
with test as(
select '粗磨'[点位],'X3'[轴位],'丝杆' [配件名],'2C0806000063' [ITEM],'2C0806000064' [ITEM2]
UNION ALL
select '粗磨'[点位],'X3'[轴位],'丝杆' [配件名],'2C0806000064' [ITEM],'2C0806000063' [ITEM2]
)
SELECT *,ROW_NUMBER() OVER(PARTITION BY 点位,轴位,配件名,(CASE WHEN CONVERT(BIGINT,SUBSTRING(ITEM,3,LEN(ITEM)-3))> CONVERT(BIGINT,SUBSTRING(ITEM,3,LEN(ITEM2)-3)) THEN CONCAT(ITEM2,ITEM) ELSE CONCAT(ITEM,ITEM2) END) ORDER BY ITEM ASC) [I] FROM TEST