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 |
|
ckuo@kahluadesigns.com
Yak Posting Veteran
58 Posts |
Posted - 2002-11-08 : 14:47:44
|
| Why is this statement not returning 4.5? How can I get a decimal value?SELECT AVG(Rating) FROM TableTABLERating54 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2002-11-08 : 15:21:41
|
| Your datatype for rating is probably integer. Integer represents whole numbers only. You need to cast/convert the rating column to float or whatever. Here is a sample:CREATE TABLE asdf( col1 int not null)INSERT INTO asdf VALUES(4)INSERT INTO asdf VALUES(5)SELECT col1 FROM ASDFSELECT AVG(CAST(col1 AS float)) FROM asdf DROP TABLE ASDFEdited by - tduggan on 11/08/2002 15:27:11 |
 |
|
|
burbakei
Yak Posting Veteran
80 Posts |
Posted - 2002-11-13 : 13:57:01
|
| Another way isSELECT AVG(Rating * 1.) FROM Table |
 |
|
|
|
|
|