Sarah,
Your data needs to be normalized. Each combination of diet and ID should create a record in a junction table. You can get there by creating a union query.
Select ID, 1 as Num, Diet1 as Diet
From [ your table]
Union all
Select ID, 2, Diet2
From [ your table]
Where Diet2 is not null
Union all
Select ID, 3, Diet3
From [ your table]
Where Diet3 is not null
Union all
Select ID, 4, Diet4
From [ your table]
Where Diet4 is not null;
You can now create a totals query based on the union query.I
I would change the table structure of it was my application.
Duane
On May 21, 2019, at 8:22 AM, "sarahk@... [MS_Access_Professionals]" <MS_Access_Professionals@yahoogroups.com> wrote:
I have a query with participants name and up to 4 special diets for each: ID, diet1, diet2, diet3, diet4.
I need to count the total numbers for each diet. I think I would need to use TRANSFORM COUNT(diet1) etc, but since it is 4 separate columns I am not sure how to do this and how to GROUP it so that I get only one column:
eg :NOSUGAR total nn
NOSALT total nn
the total would be based on all 4 columns combined.
All help is greatly appreciated.
Sarah
Posted by: sarahk@schemesoftware.com
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (19) |
Tidak ada komentar:
Posting Komentar