Tuesday, February 10, 2015

DISPLAYING NAMES MONTH WISE AND NO OF EMPLOYEES AND NAMES

SELECT DATENAME(MM,E1.HIRE_DATE)'MONTH' ,COUNT(*) 'NO OF EMPLOYEES', STUFF((SELECT ',' + E2.FIRST_NAME
FROM
 EMPLOYEE_NANDU AS E2
WHERE DATENAME(MM,E1.HIRE_DATE)=DATENAME(MM,E2.HIRE_DATE)
 FOR XML PATH('')), 1,1,'')AS ENAME
FROM EMPLOYEE_NANDU AS E1 WHERE HIRE_DATE IS NOT NULL GROUP BY DATENAME(MM,HIRE_DATE)

No comments:

Post a Comment