View Full Version : no nothing


jenjenb
09-14-2005, 07:37 AM
I am not an access savy person. I have to find all the combinations in some data 4 combo, 3 combo and 2 combo.

data looks like this

q3_1 q3_2 q3_3 q3_4

1 2 5 10
2 3 4 6
3 18 10 11


etc. I need to get all combos in the above scenario. It can be in any of the cols. There is no particular order.

HELP!! I can get the combo for all for but don't know how to get if for 3 and 2.

Desparate

Thanks

Jon K
09-14-2005, 09:54 AM
The following query shows all the combinations of four items:-

SELECT
[q3_1] & "x" & [q3_2] & "x" & [q3_3] & "x" & [q3_4] AS Combo4,

[q3_1] & "x" & [q3_2] & "x" & [q3_3] AS Combo3a,
[q3_1] & "x" & [q3_2] & "x" & [q3_4] AS Combo3b,
[q3_1] & "x" & [q3_3] & "x" & [q3_4] AS Combo3c,
[q3_2] & "x" & [q3_3] & "x" & [q3_4] AS Combo3d,

[q3_1] & "x" & [q3_2] AS Combo2a,
[q3_1] & "x" & [q3_3] AS Combo2b,
[q3_1] & "x" & [q3_4] AS Combo2c,
[q3_2] & "x" & [q3_3] AS Combo2d,
[q3_2] & "x" & [q3_4] AS Combo2e,
[q3_3] & "x" & [q3_4] AS Combo2f,

[q3_1] AS Combo1a,
[q3_2] AS Combo1b,
[q3_3] AS Combo1c,
[q3_4] AS Combo1d

FROM [TableName];
.

jenjenb
09-14-2005, 10:16 AM
Thanks Jon K.

Just one little stupid question. Is there any way to count how many of each of the combinations there are.

Ex. if 13 x 14 x12 shows up 3 times. There is a count col. that say 3.

Thanks so much.

Jon K
09-14-2005, 11:06 AM
It's possible, but not easy, and you have to use VBA.

Since 13x14x12, 13x12x14, 14x12x13, etc. belong to the same combination, you have to sort the four items in the first record. Then you need to store all the combinations of the four items in one column in a table. Then you can do the same for each of the rest of the records, storing every combination in the same column.

Finally, you can build a Totals Query based on the column of combinations to get the number of occurrences for each combination.
.

jenjenb
09-14-2005, 11:21 AM
Thank you again. You were very helpful and saved me in ways you will never know. :)