Access中的ConcatRelated(),使用两个键 [英] ConcatRelated() in Access, using two keys

查看:94
本文介绍了Access中的ConcatRelated(),使用两个键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找到了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

您能在括号内为我提供一些需要帮助的论点吗?

解决方案

您可以这样写:

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

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?

解决方案

You could write it this way:

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

这篇关于Access中的ConcatRelated(),使用两个键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆