manoj kumar singh manoj kumar singh - 7 months ago 32
SQL Question

Count records for every month in a year

I have a table with total no of 1000 records in it.It has the following structure:

EMP_ID EMP_NAME PHONE_NO ARR_DATE
1 A 545454 2012/03/12


I want to calculate no of records for every month in year-2012

Is there any way that should solve my issue in a single shot?

I tried:

select count(*)
from table_emp
where year(ARR_DATE) = '2012' and month(ARR_DATE) = '01'

Dan Dan
Answer
SELECT    COUNT(*) 
FROM      table_emp 
WHERE     YEAR(ARR_DATE) = '2012' 
GROUP BY  MONTH(ARR_DATE)