Access中的ConcatRelated(),使用两个键

时间:2012-12-11 15:08:04

标签: ms-access concatenation

我找到了ConcatRelated()函数[http://allenbrowne.com/func-concat.html],它似乎做了我想要的,但我需要输入两个键而不是一个。< / p>

我的数据如下:

Chain    Store      Warehouse
Walmart  Tucson     Phoenix
Walmart  Tucson     Flagstaff
Walmart  Phoenix    Phoenix
Bi-Lo    Phoenix    Phoenix
Bi-Lo    Phoenix    Flagstaff

我需要根据Chain和Store进行连接:

Chain    Store      Warehouses
Walmart  Tucson     Phoenix, Flagstaff
Walmart  Phoenix    Phoenix
Bi-Lo    Phoenix    Phoenix, Flagstaff

你能帮我解决一下我需要在括号内使用的论点吗?

1 个答案:

答案 0 :(得分:2)

你可以这样写:

SELECT Distinct
  tbl.Chain,
  tbl.Store,
  ConcatRelated("Warehouse","tbl","Chain=""" & [Chain] & """ and Store=""" & [Store] & """") AS Warehouses
FROM tbl;