shah Momin

shah Momin

  • NA
  • 176
  • 21.4k

Getting count of total present and absent in single sql query

Aug 29 2022 9:09 PM

 

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)