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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Help with Round Function

Author  Topic 

zwheeler
Starting Member

25 Posts

Posted - 2011-09-28 : 11:12:27
Hi
I am using the round function in my select statement and it works for the following


Round(avg(h.mtr_fass_score)) as mtr_fass, <------THIS WORKS

Round(avg(case when p.mtr_unit_count is null then null else f.mtr_5100t / ( p.mtr_unit_count * 12 ) end )) as mtr_grs_rent_unit, <--- this does not work

What am i doing wrong in this case or is this possible

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-09-28 : 11:14:25
it might be divide by zero error. try

Round(avg(case when p.mtr_unit_count is null then null else f.mtr_5100t / ( nullif(p.mtr_unit_count,0) * 12 ) end )) as mtr_grs_rent_unit

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

zwheeler
Starting Member

25 Posts

Posted - 2011-09-28 : 11:37:19
Thanks
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-09-28 : 11:48:57
wc

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -