0
Good morning, I have a school activity in which I aim to develop the consultations sql’s for each question. The activity has 1000 megasena results, containing the columns sorteio
, data_sorteio
, dezena1
, dezena2
, dezena3
, dezena4
, dezena5
and dezena6
. One of the questions is "Which was the most drawn ball?"
SELECT COUNT(dezena5), dezena5 as bola FROM megasena
GROUP BY dezena
UNION
SELECT COUNT(dezena6), dezena6 as bola FROM megasena
GROUP BY dezena6;
As for example the ball 1 can appear in all tens, I have to add up how many times it appeared in each dozen, and then all?
And as I present only the one who most appeared?
You said "the 1 ball can appear in all tens", where exactly do you take this data from? The "dozens" are the numbers?
– Mauro Alexandre
Yes, there are ten numbers. Here is a print that can help: https://prnt.sc/116ikbt .
– Thiago Giebmeyer
man, I was trying to tweak the code a little bit but I think that then you would have different queries, no? I mean, it would be a single query to bring total by ten, overall total and the one that most appeared, or would be different consultations?
– rLinhares
The answer has to be the amount of times that the ball appeared and which was the ball that appeared the most, I mean, I have to count each ball in each ten and then add the count for equal balls, and present among those balls which was the one that has the highest count.
– Thiago Giebmeyer
I am without having to write a detailed and documented reply, but see a solution here https://paiza.io/projects/uhYZVnH3pYVdoUhshBQ7g?language=mysql
– Augusto Vasques
Thank you very much, that’s exactly it!!!
– Thiago Giebmeyer