结合行 - 对面的联盟 [英] Combining Rows-Opposite of Union
问题描述
您好,
我根据匹配信息组合多行。例如我有下表。
IOSC:特写:
00029 LH
00029 SWFTERM
00029 WATS
00031 1PTY
00031巴士
00031 FR
00031 LS
00031 SWFBOTH
00031 TC
00573 FAXTHRU
00963 1PTY
00963巴士
00963 FR
00963 LS
00963 SWFBOTH
$ b $ 00 00963 TC
我希望它显示的是
IOSC:FEATURE:
00029 LH,SWFTERM,WATS
00031 PTY,BUS,FR,LS,SWFBOTH,TC
$ b $ 00 00573 FAXTHRU
00093 1PTY,BUS,FR,LS,SWFBOTH,TC
有人能想到可以用来获得预期结果的查询吗?
谢谢。
Hello,
I am tyring to combine several rows based on matching information..For example i have the following table.
IOSC: FEATURE:
00029 LH
00029 SWFTERM
00029 WATS
00031 1PTY
00031 BUS
00031 FR
00031 LS
00031 SWFBOTH
00031 TC
00573 FAXTHRU
00963 1PTY
00963 BUS
00963 FR
00963 LS
00963 SWFBOTH
00963 TC
What I want it to display is
IOSC: FEATURE:
00029 LH,SWFTERM,WATS
00031 PTY, BUS, FR, LS, SWFBOTH, TC
00573 FAXTHRU
00093 1PTY, BUS, FR, LS, SWFBOTH, TC
Can anyone think of a query that can be used to get the desired results?
Thank you.
推荐答案
我能想到的唯一方法并不是严格意义上的SQL。
你需要一个函数来保存之前记录传递的内容(直到在IOSC中更改)并返回到目前为止的连接列表。
然后必须对基于该查询的SELECT查询的结果进行分组,并且返回的字符串的Max()值将是您所需要的。
我提到它是非常kludgy?
The only way that I can think of is not strictly within SQL.
You''d need a function that saved what it had been passed by previous records (until change in IOSC) and returned the concatenated list so far.
The results of a SELECT query based on that would then have to be grouped and the Max() value of the returned string would be what you require.
Did I mention it was very kludgy?
我对VB不太了解。有什么建议吗?
I am not too savvy with VB..Any suggestions?
将此函数粘贴到模块中,然后使用下面的SQL运行查询。
Paste this function into a module then run a query with the SQL below.
这篇关于结合行 - 对面的联盟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!