0

我有一张桌子,这张桌子包含result column一些条目。我只是想知道如何使用这样的 MySql Query 对这些条目进行单独计数(请参阅所需的结果)......另外(请参阅结果列图像和查询)或帮助绝对值得赞赏

结果列图像

在此处输入图像描述

询问

SELECT cpd.result FROM cron_players_data cpd
WHERE cpd.`status` = '1' 
AND (cpd.`result` = '1' OR cpd.`result` = '2') 
AND cpd.`player_id` = '81'

结果必填

result count
1      2
2      6
4

2 回答 2

0
SELECT result, COUNT(result) `count` FROM
(
    SELECT cpd.result result 
    FROM cron_players_data cpd
    WHERE cpd.`status` = '1' 
        AND (cpd.`result` = '1' OR cpd.`result` = '2') 
        AND cpd.`player_id` = '81'
) a
GROUP BY result
于 2012-06-19T10:23:18.203 回答
0
SELECT cpd.result, count(*) FROM cron_players_data cpd
WHERE cpd.`status` = '1' 
AND (cpd.`result` = '1' OR cpd.`result` = '2') 
AND cpd.`player_id` = '81' group by cpd.`result`
于 2012-06-19T10:23:55.363 回答