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 |
|
glynd
Starting Member
1 Post |
Posted - 2005-09-22 : 14:00:03
|
| I have a SQL database and I need to add all of the test scores (kept in separate columns by class name) for each individual. How can I sum all of the test scores in a row not a column. Thanks |
|
|
MichaelP
Jedi Yak
2489 Posts |
Posted - 2005-09-22 : 14:06:14
|
| Do a search or some reading about WITH ROLLUPThat might help ya out.Michael<Yoda>Use the Search page you must. Find the answer you will. Cursors, path to the Dark Side they are. Avoid them, you must. Use Order By NewID() to get a random record you will.</Yoda> |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2005-09-22 : 16:44:04
|
| I suspect you may wish to read up on normalization:http://www.datamodel.org/NormalizationRules.htmlSounds like your data is not normalized -- you should not be modelling each class name in different columns, but rather in different rows in your table. A fully normalized database makes SELECT statements and other T-SQL statements much easier, shorter and more efficient. |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2005-09-22 : 18:31:21
|
Have you tried this?select Name, Total_of_Test_Scores = test1 + test2 + test3 + test4from MyTable CODO ERGO SUM |
 |
|
|
graz
Chief SQLTeam Crack Dealer
4149 Posts |
Posted - 2005-09-22 : 21:32:18
|
| (Moved to the T-SQL forum.)===============================================Creating tomorrow's legacy systems today.One crisis at a time. |
 |
|
|
|
|
|