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 |
|
shapper
Constraint Violating Yak Guru
450 Posts |
Posted - 2007-03-23 : 13:40:31
|
| Hello,I am creating an average rating as follows:SELECT @AvgDocRating = ROUND(AVG(DocRating), 0)FROM DocsDocRating is of type TinyIntHowever, I want to change this to return not a integer but a double with two decimal places such as:2.32, 4.34, 2.67, ...How can should my code become and what data type should I use to AvgDocRating?Thanks,Miguel |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2007-03-23 : 13:56:06
|
| [code]declare @AvgDocRating decimal(10,2)SELECT @AvgDocRating = ROUND(AVG(convert(decimal(10,2),DocRating)),2)FROM Docs[/code]CODO ERGO SUM |
 |
|
|
|
|
|