使用Allen Browne的ConcatRelated功能无法正确返回。
示例:
OrderNumber Product Types
00054001021 ROUND
00054001021 WHITE
00054001121 CONCAVE
00054001121 SCORED
00054001121 WHITE
00054001221 CAPSULE
00054001221 SCORED
00054001221 WHITE
使用此:
SELECT DISTINCT YourTable2.OrderNumber, ConcatRelated("[Product Types]","YourTable2","[OrderNumber]="& "[OrderNumber]","[Product Types]",",") AS All_Product_Types
FROM YourTable2;
返回每个订单号的所有ProductType:
OrderNumber All_Product_Types
00054001021 CAPSULE,CONCAVE,ROUND,SCORED,SCORED,WHITE,WHITE,WHITE
00054001121 CAPSULE,CONCAVE,ROUND,SCORED,SCORED,WHITE,WHITE,WHITE
00054001221 CAPSULE,CONCAVE,ROUND,SCORED,SCORED,WHITE,WHITE,WHITE
应该是:
OrderNumber All_Product_Types
00054001021 ROUND, WHITE
00054001121 CONCAVE, SCORED, WHITE
00054001221 CAPSULE, SCORED, WHITE
我做错了什么?
答案 0 :(得分:0)
我实际上是自己解决了这个问题。我需要更多的引号("),因为我的订单号字段是文本。如果其他人有相同的问题,查询应如下所示: SELECT DISTINCT YourTable2.OrderNumber,ConcatRelated(" [Product Types]"," YourTable2"," [OrderNumber] =""" & [OrderNumber]&""""," [产品类型]",",")AS All_Product_Types 来自YourTable2;