Solved

How would i get multiple sum of rows in one query?

Posted on 2006-10-24
3
216 Views
Last Modified: 2006-11-18
How would I, structure a query so that i could get back multiply row sums?

This is what i have:

SELECT  SUM(T1) as Total
FROM table name

What i need is SUM of T2 and T3 also and Then add up T1,T2, and T3 as a table named GTotal

Thanks for any help!
0
Comment
Question by:bmanmike39
3 Comments
 
LVL 92

Assisted Solution

by:Patrick Matthews
Patrick Matthews earned 150 total points
ID: 17800477
Hi bmanmike39,

Not sure what you're after, but you could do something like:

SELECT SUM(Column1) AS Total1, SUM(Column2) AS Total2, SUM(Column3) AS Total3
FROM SomeTable

Regards,

Patrick
0
 
LVL 6

Assisted Solution

by:Gokulm
Gokulm earned 150 total points
ID: 17801021
If the table GTotal is already present you could use the below query

INSERT GTotal SELECT 'field1', SUM(T1) + SUM(T2) + SUM(T3), 'field3' FROM tablename

If the table GTotal is to be created with this sum you could use the below query

SELECT 'field1' AS 'name1', SUM(T1) + SUM(T2) + SUM(T3) AS 'Total', 'field3' AS 'descr' INOT GTotal  FROM tablename
0
 
LVL 29

Accepted Solution

by:
Gautham Janardhan earned 200 total points
ID: 17801222
select sum(T1), sum(T2), sum(T1+T2)  as GTotal from TABLE1

U can do it in one query, instead of using a table
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question