user total present count
user total absent count
i wan excat data as shown in this picturce
i wan same data in this code (attced)
SQL
USE [BiometricDB]
GO
/****** Object: StoredProcedure [dbo].[sp_GetAttendanceReport] Script Date: 02/07/2023 05:22:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[sp_GetAttendanceReport]
@month INT, @year INT
AS
BEGIN
-- Attendance Report
SELECT
[present].[Month Name], [present].[Year], [present].[Total Present], [absent].[Total Absent]
FROM
(
SELECT
SUM(duration) AS [Total Present], MONTH(dutydatetime) AS [Month], YEAR(dutydatetime) AS [Year], DATENAME(month,dutydatetime) AS [Month Name]
FROM
tblattENDancelog
WHERE
[type] = 'Present' AND YEAR(dutydatetime) = @year AND MONTH(dutydatetime) = @month
GROUP by
DATENAME(month,dutydatetime), MONTH(dutydatetime), YEAR(dutydatetime)
) [present] INNER JOIN
(
SELECT
SUM(duration) AS [Total Absent], MONTH(dutydatetime) AS [Month], YEAR(dutydatetime) AS [Year]
FROM
tblattENDancelog
WHERE
[type] = 'Absent' AND YEAR(dutydatetime) = @year AND MONTH(dutydatetime) = @month
GROUP by
DATENAME(month,dutydatetime), MONTH(dutydatetime), YEAR(dutydatetime)
) [absent] ON
[present].Month = [absent].Month and [present].Year = [absent].Year
ORDER by
[present].Month
END
Amit MohantyRank #112 · 20K reputationPosted Feb 7, 2023, 6:28 AM EST
Check this
USE [BiometricDB] GO /****** Object: StoredProcedure [dbo].[sp_GetAttendanceReport] Script Date: 02/07/2023 05:22:40 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[sp_GetAttendanceReport] @month INT, @year INT AS BEGIN -- Attendance Report SELECT [present].[Month Name], [present].[Year], [present].[Total Present], [absent].[Total Absent] FROM ( SELECT COUNT(*) AS [Total Present], MONTH(dutydatetime) AS [Month], YEAR(dutydatetime) AS [Year], DATENAME(month,dutydatetime) AS [Month Name] FROM tblattENDancelog WHERE [type] = 'Present' AND YEAR(dutydatetime) = @year AND MONTH(dutydatetime) = @month GROUP by DATENAME(month,dutydatetime), MONTH(dutydatetime), YEAR(dutydatetime) ) [present] INNER JOIN ( SELECT COUNT(*) AS [Total Absent], MONTH(dutydatetime) AS [Month], YEAR(dutydatetime) AS [Year] FROM tblattENDancelog WHERE [type] = 'Absent' AND YEAR(dutydatetime) = @year AND MONTH(dutydatetime) = @month GROUP by DATENAME(month,dutydatetime), MONTH(dutydatetime), YEAR(dutydatetime) ) [absent] ON [present].Month = [absent].Month and [present].Year = [absent].Year ORDER by [present].Month ENDGuest UserRank #1,881 · 787 reputationPosted Feb 8, 2023, 1:09 AM EST
query is working this query work on this chart
Sorry bad English