Solved

Retrieving multiple records from a dataset and listing the results on one line in a msquery statement

Posted on 2011-09-06
2
220 Views
Last Modified: 2012-05-12
I have a table that has multiple  event records for one member. Is there a way in a MsQuery statement to loop through 10 times to get the next record in a set. A simplistic look at what I want to see is:
    Member1, Event1,Event2,Event3,Event4,Event5,Event6,Event7,Event8,Event8,Event9
    instead of:
    Member1 Event1
    Member1 Event2
    Member1 Event3
    Member1 Event4
    Member1 Event5
    Member1 Event6
    Member1 Event7
    Member1 Event8
    Member1 Event9
    Member1 Event10
   
0
Comment
Question by:morinia
2 Comments
 
LVL 24

Accepted Solution

by:
mankowitz earned 350 total points
ID: 36492848
if you are using mysql, you have the group_concat operator, but I think you are using MS Query and MSSQL as a back end. In that case, you have to make a subquery and concatenate all the results. See this link:

http://databases.aspfaq.com/general/how-do-i-concatenate-strings-from-a-column-into-a-single-row.html
0
 
LVL 22

Assisted Solution

by:Flyster
Flyster earned 150 total points
ID: 36492891
I'm not sure about the query, but if your results are appearing in excel as listed above, you can copy it, selct paste special and select transpose. This will give you the result you're looking for. You can use a macro like this:

Sub Transpose()
Range("A1:B10").Select '<Select the copy range here
    Selection.Copy
    Sheets("TragetSheetName").Select 'Set destination range here
    Range("TargetCell").Select
    Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
        False, Transpose:=True
End Sub

0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question