with claimPendingStatuses as ( select distinct case when c.acknowledgedDate is not null then 'Closed' when c.claimStatus = 'PENDING' and c.pendingDate is not null and c.lastDraftSavedDate is not null then 'In Progress' when c.claimStatus = 'PENDING' and c.pendingDate is not null and c.lastDraftSavedDate is null then 'Pending Review' end as claimPendingStatus from tbl_TPM_Claims c with (nolock) where c.ownerId = and c.ownerType = and c.pendingDate is not null and c.claimStatus is not null ) #forJSON( 'claimPendingStatuses', attributes.datastore, 'claimPendingStatus desc' )#