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 |
|
SAMHOR
Starting Member
1 Post |
Posted - 2012-04-30 : 13:25:56
|
| Hello All, I need to divide my sum by my count. I've so far got thisSELECT SUM (PLAYERTOTALSCORE), COUNT(playertotalscore)FROM GAME_PLAYER;Everytime i try to use / for divide it breaks :( |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2012-04-30 : 13:57:48
|
| What do you mean, "breaks"?Actual error?No error, no data?How to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxFor ultra basic questions, follow these links.http://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
 |
|
|
vijays3
Constraint Violating Yak Guru
354 Posts |
Posted - 2012-04-30 : 14:07:52
|
| [code]Please provide sample data desired output .so that we can try to provide you solution [/code] |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-04-30 : 14:25:13
|
Whats the cause of breakage? is it divide by 0?if yes, below should sort it outSELECT SUM (PLAYERTOTALSCORE)/NULLIF(COUNT(playertotalscore),0)FROM GAME_PLAYER ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
vinu.vijayan
Posting Yak Master
227 Posts |
Posted - 2012-05-01 : 07:57:10
|
| Yes, Visakh's query should work fine.N 28° 33' 11.93148"E 77° 14' 33.66384" |
 |
|
|
|
|
|