Sample Header Ad - 728x90

In MS Access 2019, how do I find numbers in a lottery table that appear often together?

-1 votes
1 answer
150 views
I have a table with 256 lottery drawings, pick 5, along with the drawing date. **I want to know how many times my favorite numbers (4,7,47) or any numbers, came out at the same drawing.** I am thinking
select * from lotto where
ball1 = 4, or ball2 = 4, or ball3 = 4, or ball4 = 4, or ball5 = 4
and
ball1 = 7, or ball2 = 7, or ball3 = 7, or ball4 = 7, or ball5 = 7
and
ball1 = 47, or ball2 = 47, or ball3 = 47, or ball4 = 47, or ball5 = 47
But I am not sure if this is the correct approach. I also want to do this with any 3 numbers, or hell, find which 3 numbers have appeared together, from all combinations of # of total balls. Thanks for your time. EDIT: I have found the solution for any 3 given numbers.
SELECT lotto.ball1, lotto.ball2, lotto.ball3, lotto.ball4, lotto.ball5
FROM lotto
WHERE
(
((lotto.ball1)=4) OR ((lotto.ball2)=4) OR ((lotto.ball3)=4) OR ((lotto.ball4)=4) OR ((lotto.ball5)=4)
)
AND
(
((lotto.ball1)=7) OR ((lotto.ball2)=7) OR ((lotto.ball3)=7) OR ((lotto.ball4)=7) OR ((lotto.ball5)=7)
)
AND
(
((lotto.ball1)=47) OR ((lotto.ball2)=47) OR ((lotto.ball3)=47) OR ((lotto.ball4)=47) OR ((lotto.ball5)=47)
)
;
Now, I wonder how to analyze the database to show ALL drawings where ANY permutation of 3 numbers came out together. Off to google I suppose. I will update this question if I find an answer -- or I will "answer" my own question.
Asked by David Ochoa (1 rep)
Nov 24, 2022, 09:49 AM
Last activity: Jul 23, 2025, 01:02 PM