sum of counts on 2 different tables

Database
Enthusiast

sum of counts on 2 different tables

There are 2 tables lets say A and B available and i need to findout the sum of count(*) from both the tables A&B together as the answer.

Please help me.
2 REPLIES
Enthusiast

Re: sum of counts on 2 different tables

sel count(*),a from customers,(sel count(*) from orders) as t(a)

above query will give the number of rows present in both tables.

Below query will give the summation of both tables

sel count(*)+a from customers,(sel count(*) from orders) as t(a)
Enthusiast

Re: sum of counts on 2 different tables


something like this ?

SELECT ACNT.CNT + BCNT.CNT AS TOTCNT
FROM
(SELECT COUNT(*) FROM A)ACNT(CNT),
(SELECT COUNT(*) FROM B)BCNT(CNT)