December 5, 2014 at 9:03 am
Hi,
Can you please help to solve this?
I have a table with many identical rows which has different numerical value only in once column.
I want these two or more identical rows to be selected as only one row with the sum of all different numerical values.
Example:-
Row1: A B 4 C D
Row2: A B 5 C D
Output: A B 9 C D
Thanks,
Sandeep
December 5, 2014 at 9:09 am
ssandeepksh (12/5/2014)
Hi,Can you please help to solve this?
I have a table with many identical rows which has different numerical value only in once column.
I want these two or more identical rows to be selected as only one row with the sum of all different numerical values.
Example:-
Row1: A B 4 C D
Row2: A B 5 C D
Output: A B 9 C D
Thanks,
Sandeep
This has to be homework since you would learn about aggregates in your first few weeks or even days of using SQL. So here's a suggestion to help you, as a full answer would teach you nothing at all.
Try GROUP BY and SUM().
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
December 5, 2014 at 2:02 pm
SELECT column_A,
column_B,
SUM(Column_4)
column_C,
column_D
FROM dbo.Test_Table
GROUP BY column_A,
column_B,
column_C,
column_D
December 8, 2014 at 4:18 am
I have been moron last week and asked such a silly question. Thanks for your help ๐
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply