2
Answers

Getting count of total present and absent in single sql query

shah Momin

shah Momin

2y
723
1

 

Check This Code

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[GetAttendanceLogweekly]AS
BEGINSET NOCOUNT ON;SELECT YEAR(dutydatetime) [Year], Count(1) [dutydatetime] 
,COUNT(case when @@FETCH_STATUS ='Absent' then 1 end ) as Absent_Count
,Count (Case When @@FETCH_STATUS = 'Present' then 1 end ) as Present_Count
FROM tblattendancelog
GROUP BY YEAR(dutydatetime)
ORDER BY 1,2END

absent and present Count Diffrent Columns with 

Answers (2)