答案 0 :(得分:0)
您可以使用:
if (is_number($year))
{
$query = $this->db->query("select sum(if(month(date)=1 and year(date) = {$year},1,0)) as month1,
sum(if(month(date)=2 and year(date) = {$year},1,0)) as month2,
sum(if(month(date)=3 and year(date) = {$year},1,0)) as month3
from `table`");
return $query->first_row();
}
等...