user73118 user73118 - 1 year ago 147
SQL Question

Select count(*) from multiple tables

How can I select count(*) from two different tables (call them tab1 and tab2) having as result:

Count_1 Count_2
123 456


I've tried this:

select count(*) Count_1 from schema.tab1 union all select count(*) Count_2 from schema.tab2

But all I have is:


Answer Source
        SELECT COUNT(*)
        FROM   tab1
        ) AS count1,
        SELECT COUNT(*)
        FROM   tab2
        ) AS count2
FROM    dual
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download