count(*)

Database

count(*)

Hi all!
I have tableA,tableB. COUNT(*) FROM TABLEA GIVES 1000 , COUNT(*) FROM TABLEB GIVES 2000.
i need a query to get output as

tablea tableb
1000 2000

i want to get both tables count(*) in a single query. how can i get it.

3 REPLIES
N/A

Re: count(*)

Select
Sum(Case When D1.TblName = 'TableA' Then TblCount End) As TableA
, Sum(Case When D1.TblName = 'TableB' Then TblCount End) As TableB
From
(Select 'TableA' As TblName, Count(*) As TblCount From TableA
Union
Select 'TableB' As TblName, Count(*) As TblCount From TableB)
As D1
;

The two counts will run in parallel.

Re: count(*)

select tableACount,tableBCount
from
(Select Count(*) As tableACount
From tableA ) temp1 (tableACount),
(Select Count(*) As tableBCount
From tableB) temp2 (tableBCount)
;

Re: count(*)

Thank you very much Jimm and Suhel.m