> Your base issue is an un-normalized table. You could create a union query to
> normalize your second table and then link in another query to your first
[quoted text clipped - 43 lines]
> >
> > Sergio.
>Can you also tell me how the table should be designed for it to be
>normalized? Suppose the first table is called PRODUCTS and the second
>one is called CHOICE.
If you have three choices, your Field1, Field2, Field3, then they
should be in three ROWS, not three fields. "Fields are expensive,
records are cheap"!
John W. Vinson[MVP]
John is correct regarding fields vs records.
Your union query would be like:
==quniNormalChoice=======
SELECT ID, Field_1 as ID, "FIELD_1" as Colhead
FROM Choice
UNION ALL
SELECT ID, Field_2, "FIELD_2"
FROM Choice
UNION ALL
SELECT ID, Field_3, "FIELD_3"
FROM Choice;
Then create a crosstab based on quniNormalChoice that would use the Product
table.
TRANSFORM Val(Nz(Count([IDF]),0)) AS Expr1
SELECT [Product Name]
FROM Products INNER JOIN quniNormalChoice ON Products.ID =
quniNormalChoice.ID
GROUP BY [Product Name]
PIVOT quniNormalChoice.Colhead;

Signature
Duane Hookom
MS Access MVP
> Duane:
>
[quoted text clipped - 59 lines]
>> >
>> > Sergio.
einsteinhelpme@yahoo.com - 11 Aug 2006 05:31 GMT
I want to thank all of you for your advices. Before I could read your
last post I have worked out a solution. As you
previously said, table 2 (CHOICE), is ill-prepared for what I want to
do, so I had to create a union query to solve this.
This query would be:
SELECT Product_Name as PName, 1 as Order
FROM CHOICE, PRODUCTS
WHERE FIELD_1 = PRODUCTS.ID
UNION ALL
SELECT Product_Name as PName, 2 as Order
FROM CHOICE, PRODUCTS
WHERE FIELD_2 = PRODUCTS.ID
UNION ALL
SELECT Product_Name as PName, 3 as Order
FROM CHOICE, PRODUCTS
WHERE FIELD_3 = PRODUCTS.ID;
This query (lets name it ARRANGED_DATA) contains now the names of the
brands along with the order of appearance. (It's very
important the ALL keyword, which indicates that the query must include
duplicated values.)
Having done this, is easy to set up another query to obtain the final
results:
SELECT PName AS Products,
-sum(Order=1) AS Place_1,
-sum(Order=2) AS Place_2,
-sum(Order=3) AS Place_3
FROM ARRANGED_DATA
GROUP BY PName;
And that's all folks! Yes, I know it's very nasty the
-sum(BOOLEAN_EXPRESSION), but right now I can't figure out something
neater as a replacement for it (i.e. to count the YES occurrences in
the boolean expression). If you know something better,
I'd like to know about it.
I guess the solution you propose is better and I'll use it instead of
this one I listed here.
Thanks again for your time and concern.
Sergio
Duane Hookom ha escrito:
> John is correct regarding fields vs records.
>
[quoted text clipped - 85 lines]
> >> >
> >> > Sergio.