I have two queries, they give me a TOTAL number. I need to add the total of both queries and give me a TOTALSUM from both, the queries are below. Help is appreciated
1. QUERY # 1
SELECT COUNT(Cases.Id) AS TOTAL
LEFT JOIN Users ON AlienId = UserId
INNER JOIN Processcatalog ON Process = ProcesscatalogID
INNER JOIN Activities ON Activities.CaseId = Cases.Id
INNER JOIN Atts AS b ON Cases.Id = b.CaseId
LEFT JOIN Users AS e ON e.UserId = Cases.EmpId
WHERE Activities.ActType = 'HISTORY'
AND Cases.FirmId = 2
AND ( DATEADD(DAY, Activities.responsible, Activities.LastModified) < GETDATE() )
AND b.UserId = 1713
AND Activities.DateInitiated IS NULL
AND Cases.Archived = 0;
2. QUERY # 2
SELECT COUNT(*) AS TOTALCASES
FROM Activities a
INNER JOIN Cases AS b ON a.CaseId = b.Id
INNER JOIN Atts AS d ON d.CaseId = b.Id
INNER JOIN Users AS c ON a.responsible = c.UserId
INNER JOIN Users AS e ON b.AlienId = e.UserId
WHERE a.FirmId = 2
AND ( a.ActType = 'TASK'
OR a.ActType = 'DEADLINE'
AND a.Complete = '0'
AND d.UserId = 1713
AND a.DateInitiated < LEFT(DATEADD(DAY, 0, GETDATE()), 12)
AND b.Archived <> 1;
We need to add total from query one + total from query 2 to get totalsum