小编典典

从多个表中选择 count(*)

all

我如何count(*)从两个不同的表中进行选择(调用它们tab1tab2),结果是:

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

阅读 79

收藏
2022-05-07

共1个答案

小编典典

SELECT  (
        SELECT COUNT(*)
        FROM   tab1
        ) AS count1,
        (
        SELECT COUNT(*)
        FROM   tab2
        ) AS count2
FROM    dual
2022-05-07