本文介绍了从多个表中选择count(*)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何从两个不同的表(称为 tab1
和 tab2
)中选择 count(*)
结果:
How can I select count(*)
from two different tables (call them tab1
and tab2
) having as result:
Count_1 Count_2
123 456
我已经试过了:
select count(*) Count_1 from schema.tab1 union all select count(*) Count_2 from schema.tab2
但我只有:
Count_1
123
456
推荐答案
SELECT (
SELECT COUNT(*)
FROM tab1
) AS count1,
(
SELECT COUNT(*)
FROM tab2
) AS count2
FROM dual
这篇关于从多个表中选择count(*)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!