Wednesday, January 25, 2012

Month wise Data retriving using SQL query and how to validate correct data


SELECT  YEAR(EntryDate) AS 'Year', MONTH(EntryDate) AS 'Month', COUNT(*) AS monthly_Case_count
FROM dbo.SP_Case WHERE YEAR(EntryDate)=2011
GROUP BY YEAR(EntryDate), MONTH(EntryDate)
ORDER BY YEAR(EntryDate), MONTH(EntryDate);

SELECT COUNT(*) FROM dbo.SP_Case
WHERE YEAR(EntryDate)=2011 AND MONTH(EntryDate)=2

No comments:

Post a Comment