Due to the huge Powerball $2.3 billion jackpot, I was wondering how does one query a lottery database where there are columns num1, num2, num3, num4, num5, num6 for a certain draw date and compare that to past winning numbers on itself to see if there are duplicate sets? (ie. if the winning numbers have ever repeated itself)?
Couldn't think of how to query - I am a newbie in SQL
CodePudding user response:
Assuming the schema was as described, you could simply GROUP BY
all six columns to see if the numbers had repeated. This would work for the jackpot, smaller prizes would require additional work.
SELECT num1, num2, num3, num4, num5, num6, COUNT(*) AS Frequency
FROM LotteryTable
GROUP BY num1, num2, num3, num4, num5, num6
HAVING COUNT(*) > 1