MYSQLでのカウント関数
case文と組み合わせれば効率的な集計が出来る
<?php select count(*) as 合計,count(case when SHANAI is null then 1 end) as お客様,count(case when SHANAI =1 then 1 end) as 社内 from tmaster inner join tperson on tmaster.J_NUM = tperson.J_NUM ?>
case文と組み合わせれば効率的な集計が出来る
<?php select count(*) as 合計,count(case when SHANAI is null then 1 end) as お客様,count(case when SHANAI =1 then 1 end) as 社内 from tmaster inner join tperson on tmaster.J_NUM = tperson.J_NUM ?>