我需要帮助我正在尝试编写一个查询,在不同情况下计算多个事物。 到目前为止,这是我能够进行单独查询的地方,但我想要做的就是将它们组合在一起
SELECT COUNT(*) AS "Marketing"
FROM PROJECT
WHERE Department = 'Marketing';
SELECT COUNT(*) AS "Number of Finance"
FROM PROJECT
WHERE Department = 'Finance';
SELECT COUNT(*) AS "Number of Accounting"
FROM PROJECT
WHERE Department = 'Accounting';
答案 0 :(得分:2)
尝试GROUP BY
SELECT Department, COUNT(*) AS Count
FROM PROJECT
WHERE Department IN ('Marketing','Finance','Accounting')
GROUP BY Department