我正在尝试对两个表进行计数并通过联合来得出结果。之后我该如何获取行的总和?
select count(PARTNER_ID) from Administrator.PARTNERS
union
select count(RECORD_ID) from Administrator.DELETED_RECORDS WHERE RECORD_BASE_TYPE = 'PARTNER'
答案 0 :(得分:3)
使用子查询
select sum(val)
from
(
select count(PARTNER_ID) as val from Administrator.PARTNERS
union all
select count(RECORD_ID) from Administrator.DELETED_RECORDS WHERE RECORD_BASE_TYPE = 'PARTNER'
)A