MySQL: Query the number of occurrences of each value of a field in a table

Scenario: I participated in a written test today, in which there is a database programming question. The topic is roughly as follows
. There is a table info, and the structure and data of the table are shown in the figure below.
write picture description here
How to query and get the results shown in the figure below
write picture description here

I didn't make it at that time. This is a written test question for a relatively difficult database that I have done.
Without further ado, let’s go straight to the answer:

SELECT idate,SUM(result='win') AS 'win',SUM(result='fail') AS fail FROM info GROUP BY idate

The answer is correct, running in mysql can get the correct result.
This article refers to the self- improving blog, thanks to his blog for explaining the confusion. I believe you should be able to understand how to get the answer after reading his blog. Well, I won't explain much here

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324606943&siteId=291194637