Ms Access Query: Concatenating Rows through a query
You need a function to do the concatenation.
Microsoft Access condense multiple lines in a table
Example using your data:
Select T.ColumnA , GetList("Select ColumnB From Table1 As T1 Where T1.ColumnA = " & [T].[ColumnA],"",", ") AS ColumnBItemsFrom Table1 AS TGroup By T.ColumnA;
Here's an outstanding link re: how to do this from within SQL by calling a function. The instructions are exceptionally clear & the function is written for you so you can just copy, paste & go. Even someone with no knowledge of VB can easily implement it:Concatenate values from related records
this can be very difficult to obtain. If you MUST do it in a query and not a function, the problem that you will run into is the limit of the number of rows you can concatenate into one column. So far the only way that i have found to achieve this is via iif statements.
SELECT test1.ColumnA AS ColumnA, First([test1].[ColumnB]) & IIf(Count([test1].[ColumnB])>1,"," & Last([test1].[ColumnB])) AS ColumnBFROM test1GROUP BY test1.ColumnA;
returns:
ColumnA ColumnB 1 abc,xyz 2 efg,hij 3 asd
This will return the first and the last only, but I'm sure with a little work you could work out the Choose function, but like I said you would have to add more iif statements for each additional item you want to add, hence the limitation.