从多个表中选择count(*)

2021-12-05 00:00:00 sql count oracle

如何从两个不同的表(称为 tab1tab2)中选择 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

相关文章