View previous topic :: View next topic |
Author |
Message |
shekar123 Advanced
Joined: 22 Jul 2005 Posts: 528 Topics: 90 Location: Bangalore India
|
Posted: Wed Jul 27, 2005 4:48 am Post subject: SQL query to get the addition of two tables records count |
|
|
I have a table A with 20 records and i get the information by giving the query SELECT COUNT(*) FROM A,Similarly i have a table B with 80 records and i get the information by giving the query SELECT COUNT(*) FROM B.Can i have a query to get the addition of the count of the records from two tables as 100 records (addition of A + B ) ? |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Wed Jul 27, 2005 6:04 am Post subject: |
|
|
shekar123,
The following SQL will give you the desired results.
Code: |
SELECT SUM(A.CNT)
FROM (SELECT COUNT(*) AS CNT
FROM TABLE1
UNION ALL
SELECT COUNT(*) AS CNT
FROM TABLE2) A
;
|
Hope this helps...
Cheers
kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
shekar123 Advanced
Joined: 22 Jul 2005 Posts: 528 Topics: 90 Location: Bangalore India
|
Posted: Thu Jul 28, 2005 1:02 am Post subject: Query for counting records from two tables |
|
|
Hai Kolusu,
You are really great.The query did run fine and the logic used for the query is excellent.Thanks.
Shekar123 |
|
Back to top |
|
 |
|
|