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.
How to query and get the results shown in the figure below
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