Any clever SQL people out there? Given the raw data on the left, (a table of test results) how do I write a SQL query to give me the results on the right, (the results grouped by date as well as grouped by result)?
4
1
3
Nice!
Apparently EXTRACT(DATE FROM col) doesn't exist in MySQL, but DATE(col) works instead. So:
SELECT DATE(date) AS date, SUM(success) AS success, SUM(IF(success, 0, 1)) AS fail
FROM results GROUP by 1 ORDER BY 1 DESC;
Sep 16, 2022 · 4:16 PM UTC


