Usf Noor Usf Noor - 2 months ago 6
SQL Question

How to get data of specific month sql

I have a student table that contain admission_date and student_status column, i want to get total admission of each month of a specific year, while admission_date column type is DateTime. i.e

**Month** **Total_Admission**
Jan-2016 90
Feb-2016 70
Mar-2016 109

Answer

Try with the below query.

SELECT replace(right(convert(varchar, admission_date, 106), 8), ' ', '-') Month,COUNT(*) TotalAdmissions
FROM yourTable
WHERE YEAR(admission_date) = 2016
GROUP BY replace(right(convert(varchar, admission_date, 106), 8), ' ', '-') 
Comments