name status a win a run a run b run b win b win c run c run c run d run d run e NA e run e win f NA f NA f NA 在mysql中 在这里我需要采取的运行计数也不赢一样的赢和不赢 有人能帮我吗? 预期产量 WIN 3 RUN 2 NA 1 已尝试的查询 SELECT a FROM data GROUP BY a HAVING ( COUNT(*) > 1 )
SELECT
name,
COUNT(CASE WHEN status = 'win' THEN 1 END) AS WIN,
COUNT(CASE WHEN status = 'run' THEN 1 END) AS run,
COUNT(CASE WHEN status = 'NA' THEN 1 END) AS NA
FROM yourTable
GROUP BY
name;
1条答案
按热度按时间7vux5j2d1#
尝试使用条件聚合: