mysql:count_if
条件ごとにCOUNTする
全件と条件ごとの集計を行う。
e.g. 有効な顧客の全数、男女を集計
SELECT COUNT(1) AS ALL , COUNT(IF(sex='M',1,NULL)) AS MALE , COUNT(IF(sex='F',1,NULL)) AS FEMALE FROM customer WHERE delflg=0
mysql/count_if.txt · 最終更新: 2014/07/08 05:30 by clownclown