Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
531 views
in Technique[技术] by (71.8m points)

concatenation - ConcatRelated() in Access, using two keys

I found the ConcatRelated() function [http://allenbrowne.com/func-concat.html] and it seems to do what I want it to, but I need to feed in two keys rather than just one.

My data looks like:

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

And I need to concatenate based on both the Chain and the Store:

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

Can you help me with the arguments I need to use within the brackets?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You could write it this way:

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...