SELECT Count(type) FROM tblattendancelog WHERE dutydatetime>= DATEADD(day, DATEDIFF(day,0,getdate()), 0)
this uper line edit down code me edit
SQL
USE [BiometricDB]
GO
/****** Object: StoredProcedure [dbo].[sp_GetTotalCountReport] Script Date: 26/10/2022 03:28:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[sp_GetTotalCountReport]
AS
BEGIN
-- Get Total Count Report
SELECT
[member].[Total Members], [onleave].[Total Onleave] ,[Present].[Total Present]
FROM
(
-- Total Memebers
SELECT
COUNT(volunteerid) AS [Total Members], 1 AS [Id]
FROM
tblvolunteer
WHERE
[dateofleaving] = '' OR [dateofleaving] IS NULL
) [member] INNER JOIN
(
-- Total OnLeave
SELECT
COUNT(leaverecordid) AS [Total Onleave], 1 AS [Id]
FROM
tblvolunteerleaverecord
WHERE
[todate] >= GETDATE()
) [onleave] ON [member].[Id] = [onleave].[Id]
END
Amit MohantyRank #112 · 20K reputationPosted Oct 26, 2022, 1:58 AM EDT
Try this
ALTER PROCEDURE [dbo].[sp_GetTotalCountReport] AS BEGIN -- Get Total Count Report SELECT [member].[Total Members], [onleave].[Total Onleave], [present].[Total Present] FROM ( -- Total Memebers SELECT [Total Members] = COUNT([volunteerid]), [Id] = 1 FROM [tblvolunteer] WHERE [dateofleaving] = '' OR [dateofleaving] IS NULL ) [member] INNER JOIN ( -- Total OnLeave SELECT [Total Onleave] = COUNT([leaverecordid]), [Id] = 1 FROM [tblvolunteerleaverecord] WHERE [todate] >= GETDATE() ) [onleave] ON [member].[Id] = [onleave].[Id] INNER JOIN ( -- Total Present SELECT [Total Present] = COUNT([type]), [Id] = 1 FROM [tblattendancelog] WHERE [dutydatetime] >= DATEADD(DAY, DATEDIFF(DAY, 0, GETDATE()), 0) ) [present] ON [member].[Id] = [present].[Id] ENDMuhammad Imran AnsariRank #326 · 7.6K reputationPosted Oct 26, 2022, 1:54 AM EDT
You question is not clear, what you want to achieve?
If you want to add abover query result in main query, mention the condition for join clause
If you want to add in existing sub query then also need to define the condition for join clause
OR you need to define your problem clearly with table structure.