SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 joining tables
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

taj
Starting Member

India
39 Posts

Posted - 09/16/2013 :  08:02:14  Show Profile  Reply with Quote
HI ALL

I HAVE 30 DIFFERENT TABLES, IN ALL 30 TABLES I HAVE FOUR COMMON COLUMNS
A,B,C,D. Now I WANNA JOINS ALL 30 TABLES AND MAKE THE SUM OF (A),SUM OF(B),SUM OF (C),SUM OF(D).

How to do this?

Thank You

khtan
In (Som, Ni, Yak)

Singapore
17638 Posts

Posted - 09/16/2013 :  08:20:29  Show Profile  Reply with Quote
SELECT SUM(A), SUM(B), SUM(C), SUM(D)
FROM   
(
    SELECT A, B, C, D FROM TABLE1 UNION ALL
    SELECT A, B, C, D FROM TABLE2 UNION ALL
    SELECT A, B, C, D FROM TABLE3 UNION ALL
    . . . 
) d



KH
Time is always against us

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000