Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
rajabadsha
Starting Member
4 Posts |
Posted - 2007-12-07 : 07:39:18
|
| I have a table named 'MyTable'. There are two columns: NUM, AVERAGE. The table has data as follows:NUM AVERAGE1 52 152 102 54 24 85 106 76 7I want to write a query that will keep the distinct number from the first column and will generate the sum for each distinct number from the second column. The result will be as following:1 52 304 105 106 14Can anyone help |
|
|
Ifor
Aged Yak Warrior
700 Posts |
Posted - 2007-12-07 : 07:44:21
|
| Read up on GROUP BY and SUM in BOL (Books online) |
 |
|
|
kiruthika
Yak Posting Veteran
67 Posts |
Posted - 2007-12-08 : 01:03:45
|
| hi!select num,sum(average) as AverageVal from mytable group by numkiruthika!http://www.ictned.eu |
 |
|
|
|
|
|