List all the constituents of a Group in another column:

Joined
Jun 26, 2011
Messages
1
Reaction score
0
Good morning everybody,

I am a beginner programmer in VBA in access and ADO. It is my first to post a message on this forum and I am more than sure that someone out there will have the answer to my problem and at least point me into the right direction.


I have to SUM the Sales and COUNT the number of Sales firstly by Category and by Products. For that I used the following code and got the result below.



Code:
[FONT=Helv][COLOR=black][COLOR=black][FONT=Helv]SELECT MyTable.Category[/FONT][/COLOR]
[COLOR=black][FONT=Helv], MyTable.Products[/FONT][/COLOR]
[COLOR=black][FONT=Helv], Sum(MyTable.Sales) AS SumOfSales[/FONT][/COLOR]
[COLOR=black][FONT=Helv], Count(MyTable.SalesPerson) AS CountOfSalesPerson[/FONT][/COLOR]
[COLOR=black][FONT=Helv]FROM MyTable[/FONT][/COLOR]
[COLOR=black][FONT=Helv]GROUP BY MyTable.Category[/FONT][/COLOR]
[COLOR=black][FONT=Helv], MyTable.Products;[/FONT][/COLOR]
[/COLOR][/FONT]



My additional (and final) requirement is to get a fourth column which will recap/list the SalesPerson and their respective Sales. But I have no clue how to get that. Any help or suggestion (in VBA or ADO ) will be welcomed. my aim is to get the 4th column (in red).


this is where I want to get: I want to be able to add a 4th column.this column will list all the constituents of each category. For instance, the Products Transport, 3 SalesPerson (alain, david and bonero) contribute respectively 5, 1 and 4. thus the 4th column , i will have : alain 5, David 1, Bonero 4.



as i am experiencing difficulties posting the tables directly in my message, I enclosed a workbook(BookHelp).
Thanks in advance for your help.
 

Attachments

  • BookHelp.zip
    2.6 KB · Views: 61

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top