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 |
|
wizard25
Starting Member
2 Posts |
Posted - 2009-09-28 : 00:35:46
|
| hey guys, I'm new to SQL and I was just wondering, how would you set out the AVG and rounding off function together. I want to set a cost to 2 decimal places. I tried the following functions, but they don't seem to work for some reason.round (AVG(cost), 2)round (AVG (cost,2))Can you guys help? |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-09-28 : 01:07:29
|
use CONVERT() or CAST to convert it to decimal(10, 2) or numeric(10, 2) KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
wizard25
Starting Member
2 Posts |
Posted - 2009-09-28 : 04:51:44
|
| so do you mean to make it asconvert (AVG(cost), 2) |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-09-28 : 05:45:13
|
convert(decimal(10,2), avg(cost)) KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|