taskStatusSummary log {ts '2025-03-03 12:02:44'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-03-03' ; with tasks as ( select t.taskId, case when t.disposition = 'X' then 'Completed' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay /* , t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, t.dispositionUser, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, t.partnerId, t.partnerType, t.partnerContactId, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, t.acknowledged, t.taskTypeId, t.repeating, t.frequency, t.repeatUntil, t.sourceTaskId */ from tbl_WRK_Tasks t with (nolock) /* inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 */ where t.ownerId = @ownerId and t.ownerType = @ownerType and t.assignedTo = ? and t.dueDate >= ? and t.dueDate <= ? ), dispositions as ( select b.* from (VALUES ( 'Past Due' ), ( 'Open'), ( 'On Hold'), ( 'Complete' ), ( 'Cancelled' ) ) AS b( display) ), tasksStatus as ( select d.display , coalesce( count( taskId), 0 ) as taskNumbers from dispositions d left outer join tasks t on t.statusDisplay = d.display group by d.display ) , tasksStatus_mappedData as ( select * from tasksStatus ) , tasksStatus_preData as ( select * from tasksStatus_mappedData with (nolock) where ( 1 = 1 ) ) , tasksStatus_data as ( select * from tasksStatus_preData ) , tasksStatus_return as ( select * from tasksStatus_data where 1 = 1 order by display offset 0 rows fetch next 20 rows only ) , tasksStatus_result as ( select ( select count(*) from tasksStatus_data ) as totalCount, ( select * from tasksStatus_return for json auto, include_null_values ) as data ) select * from tasksStatus_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER -- 3811100 -- 2024-12-29 -- 2025-12-27 {ts '2025-03-03 12:33:22'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-03-03' ; with tasks as ( select t.taskId, case when t.disposition = 'X' then 'Completed' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay /* , t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, t.dispositionUser, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, t.partnerId, t.partnerType, t.partnerContactId, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, t.acknowledged, t.taskTypeId, t.repeating, t.frequency, t.repeatUntil, t.sourceTaskId */ from tbl_WRK_Tasks t with (nolock) /* inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 */ where t.ownerId = @ownerId and t.ownerType = @ownerType and t.assignedTo = ? and t.dueDate >= ? and t.dueDate <= ? ), dispositions as ( select b.* from (VALUES ( 'Past Due' ), ( 'Open'), ( 'On Hold'), ( 'Complete' ), ( 'Cancelled' ) ) AS b( display) ), tasksStatus as ( select d.display , coalesce( count( taskId), 0 ) as taskNumbers from dispositions d left outer join tasks t on t.statusDisplay = d.display group by d.display ) , tasksStatus_mappedData as ( select * from tasksStatus ) , tasksStatus_preData as ( select * from tasksStatus_mappedData with (nolock) where ( 1 = 1 ) ) , tasksStatus_data as ( select * from tasksStatus_preData ) , tasksStatus_return as ( select * from tasksStatus_data where 1 = 1 order by display offset 0 rows fetch next 20 rows only ) , tasksStatus_result as ( select ( select count(*) from tasksStatus_data ) as totalCount, ( select * from tasksStatus_return for json auto, include_null_values ) as data ) select * from tasksStatus_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER -- 3811100 -- 2024-12-29 -- 2025-12-27 {ts '2025-03-03 17:40:25'} SQL declare @ownerId int = 207 ; declare @ownerType varchar(3) = 'MFR' ; declare @userId int = 0 ; declare @today datetime = '2025-03-03' ; with tasks as ( select t.taskId, case when t.disposition = 'X' then 'Completed' when t.disposition = 'Z' then 'Cancelled' when t.disposition = 'H' then 'On Hold' when t.disposition = '?' then case when t.dueDate is null then 'Open' when t.dueDate < @today then 'Past Due' else 'Open' end else t.disposition end as statusDisplay /* , t.taskType, cast( t.priority as int ) priority, t.ownerId, t.ownerType, t.subjectId, t.subjectType, t.sourceId, t.sourceType, t.taskDescription, t.createDate, t.createdBy, t.updateDate, t.updatedBy, t.disposition, t.dispositionUser, t.dispositionDate, t.reminderDays, t.requestedBy, r.firstName + ' ' + r.lastName as requestedByFullName, t.assignedTo, a.firstName + ' ' + a.lastName as assignedToFullName, t.dueDate, t.dueDateNotification, t.partnerId, t.partnerType, t.partnerContactId, t.reminderSent, t.taskComment, t.taskTemplateId, t.workflowRequestId, t.acknowledged, t.taskTypeId, t.repeating, t.frequency, t.repeatUntil, t.sourceTaskId */ from tbl_WRK_Tasks t with (nolock) /* inner join tbl_FSPro_Members a with (nolock) on a.fspro_userId = t.assignedTo and a.ownerId > 0 inner join tbl_FSPro_Members r with (nolock) on r.fspro_userId = t.requestedBy and r.ownerId > 0 */ where t.ownerId = @ownerId and t.ownerType = @ownerType and t.assignedTo = ? and t.dueDate >= ? and t.dueDate <= ? ), dispositions as ( select b.* from (VALUES ( 'Past Due' ), ( 'Open'), ( 'On Hold'), ( 'Complete' ), ( 'Cancelled' ) ) AS b( display) ), tasksStatus as ( select d.display , coalesce( count( taskId), 0 ) as taskNumbers from dispositions d left outer join tasks t on t.statusDisplay = d.display group by d.display ) , tasksStatus_mappedData as ( select * from tasksStatus ) , tasksStatus_preData as ( select * from tasksStatus_mappedData with (nolock) where ( 1 = 1 ) ) , tasksStatus_data as ( select * from tasksStatus_preData ) , tasksStatus_return as ( select * from tasksStatus_data where 1 = 1 order by display offset 0 rows fetch next 20 rows only ) , tasksStatus_result as ( select ( select count(*) from tasksStatus_data ) as totalCount, ( select * from tasksStatus_return for json auto, include_null_values ) as data ) select * from tasksStatus_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER -- 3811100 -- 2024-12-29 -- 2025-12-27