我在 MS Access 2010 中有一张表:
PartID PartName
C0001 CHAIR
S0001 SOFA
S0002 SOFA
S0003 SOFA
DT0001 DINNING TABLE
DT0002 DINNING TABLE
我想创建一个查询:
PartID PartName
C0002 CHAIR
S0004 SOFA
DT0003 DINNING TABLE
有人可以告诉我链接或如何做吗?谢谢!
尝试使用此查询:
SELECT
Tabel1.PartName
, RIGHT(MAX(CINT(RIGHT([PartID],4)))+10001,4) AS NewId
FROM Tabel1
GROUP BY Tabel1.PartName
带有 PartName 和前缀的查找表可用于将前缀添加到新 ID。
这已经过测试并且有效。
SELECT
LEFT([PartID], InStr([PartID], "0")-1) & RIGHT(MAX(CINT(RIGHT([PartID],4)))+10001,4) AS NPartId, tblParts.PartName
FROM tblParts
GROUP BY tblParts.PartName, LEFT([PartID], InStr([PartID], "0")-1)