我需要從 UNION ALL 的查詢中獲取計數,但到目前為止我所有的嘗試都失敗了,我無法讓它作業。
我的初始選擇(回傳 8 個獨特的部門)
select distinct Department
from ( select Department
from EFP_EmployeeFollowupManagerCommit
union all
select Department from EFP_EmploymentUser )
a order by Department;
我嘗試了以下不同的變體
SELECT COUNT(Department) as "DepCount"
FROM ( select Department
from EFP_EmployeeFollowupManagerCommit
union all
select Department
from EFP_EmploymentUser );
任何人都可以幫忙嗎?
更新!
我終于讓它作業了..謝謝大家:-)
最后查詢:
select count(*) from (
select distinct Department
from (
select Department
from EFP_EmployeeFollowupManagerCommit
union all
select Department
from EFP_EmploymentUser ) as ddep) as depcount;
uj5u.com熱心網友回復:
您可以嘗試以下查詢,它應該可以作業:
select count(*) from (select distinct Department
from ( select Department from EFP_EmployeeFollowupManagerCommit
union all
select Department from EFP_EmploymentUser ));
uj5u.com熱心網友回復:
你必須這樣寫:select count(distinct Department)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/313272.html
標籤:查询语句
上一篇:使用SQL按答案分組問題
