MySQL के साथ, आप SUM(condition)
. का उपयोग कर सकते हैं :
SELECT id, SUM(value=0) AS n0, SUM(value=1) AS n1, COUNT(*) AS total
FROM mytable
GROUP BY id
इसे sqlfiddle पर देखें ।
MySQL के साथ, आप SUM(condition)
. का उपयोग कर सकते हैं :
SELECT id, SUM(value=0) AS n0, SUM(value=1) AS n1, COUNT(*) AS total
FROM mytable
GROUP BY id
इसे sqlfiddle पर देखें ।