1.รายวัน
select regdate,count(an) cc
from an_stat
where regdate between '2011-1-1' and '2011-1-31'
and ward='01' //รหัสที่ต้องการ
group by regdate
order by regdate
2.รายเดือน
select month(regdate) 'month',year(regdate) 'year',count(an) cc
from an_stat
where regdate between '2011-1-1' and '2011-12-31'
and ward='01'
group by month,year
order by month,year
3.รายปี
select year(regdate) 'year',count(an) cc
from an_stat
where regdate between '2009-1-1' and '2011-12-31'
and ward='01'
group by year
order by year