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 |
mike13
Posting Yak Master
219 Posts |
Posted - 2015-01-08 : 06:07:35
|
a quick SQL questionim using the AVG function but is not giving me the desired resultexample: i got a 100 users that gave rating to a producthere are the valuesrating - amount5 - 5164 - 893 - 332 - 201 - 11AVG give me a 4in my view it is clearly a 5 how can achief this?thanks a lot |
|
Ifor
Aged Yak Warrior
700 Posts |
Posted - 2015-01-08 : 06:55:58
|
With integers the average is clearly 4.If you want an average of 5 you will need to convert to a float and then round.eg ROUND(AVG(Rating * 1.0), 0) |
|
|
viggneshwar
Yak Posting Veteran
86 Posts |
Posted - 2015-01-08 : 08:51:08
|
Use Ceiling function to solve this Ceiling(AVG(Rating * 1.0))RegardsViggneshwar A |
|
|
mike13
Posting Yak Master
219 Posts |
Posted - 2015-01-08 : 09:16:35
|
That worked! Thanks a lot |
|
|
|
|
|