如何求和两个不同 SQL 查询的结果?

How to SUM the result of two different SQL query?

我想对这两个不同的查询求和。我加入了 USING 功能。但它在两个不同的单元格中显示了两个结果。

我需要一个结果来对这两个查询求和,答案应该是 4069。

密码

SELECT COUNT(*) Active_Projects FROM
(SELECT ProjectID, ProjectStatusID, ClientID
FROM project) a
INNER JOIN 
(SELECT ProjectStatusID, ClientID, ProjectStatusName
FROM ProjectStatus) b
ON (a.ProjectStatusID = b.ProjectStatusID AND a.ClientID = b.ClientID)
WHERE ProjectStatusName LIKE '%active%'
AND a.ClientID = 4

UNION

SELECT COUNT(*) Total_Projects
FROM Project
WHERE ClientID=4

Picture

Screenshot

Screenshot Here

试试这个。 select query1+ query2;

select (
    SELECT COUNT(*) Active_Projects FROM
(SELECT ProjectID, ProjectStatusID, ClientID
FROM project) a
INNER JOIN 
(SELECT ProjectStatusID, ClientID, ProjectStatusName
FROM ProjectStatus) b
ON (a.ProjectStatusID = b.ProjectStatusID AND a.ClientID = b.ClientID)
WHERE ProjectStatusName LIKE '%active%'
AND a.ClientID = 4
) + (
SELECT COUNT(*) Total_Projects
FROM Project
WHERE ClientID=4) ;