Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Union All Expand / Collapse
Author
Message
Posted Tuesday, December 16, 2008 4:00 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Friday, May 30, 2014 9:06 AM
Points: 78, Visits: 329
Hi,

table A which has 4 records
union all
Table B -has 4 records --getting result set using 3 tables
union all
table c - has 4 records
..
when i use union all I'm getting 12 records altogether in a result set..
My question is i want to see the sum of all records so that i will get only 1 record in the result set.





Post #620820
Posted Tuesday, December 16, 2008 4:03 PM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 6:03 AM
Points: 40,437, Visits: 36,890
SELECT SUM(SomeColumn) FROM (
SELECT SomeColumn FROM TableA
UNION ALL
SELECT SomeColumn FROM TableB
UNION ALL
SELECT SomeColumn FROM TableC) sub




Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #620822
Posted Tuesday, December 16, 2008 4:14 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Friday, May 30, 2014 9:06 AM
Points: 78, Visits: 329
The columns in the table a ,b ,c are already using aggregate functions like max(duration) ,min(perf),avg(proc)
Post #620826
Posted Tuesday, December 16, 2008 4:23 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Friday, May 30, 2014 9:06 AM
Points: 78, Visits: 329
It worked .


Thanks Gil.
Post #620829
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse