Help with Round Function

  • 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

    thanks in advance

  • zwheeler (9/28/2011)


    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

    thanks in advance

    Hmmmmm. . . . Define "not work".


    Forever trying to learn
    My blog - http://www.cadavre.co.uk/
    For better, quicker answers on T-SQL questions, click on the following...http://www.sqlservercentral.com/articles/Best+Practices/61537/
    For better, quicker answers on SQL Server performance related questions, click on the following...http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • zwheeler (9/28/2011)


    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

    thanks in advance

    My guess would be you need to either change the code so your case statement does NOT return null, perhaps return 0 instead? Or add something to your where clause. Perhaps where p.mtr_unit_count is not null. So the null values are not part of the avg and the round.

    Ben

  • thanks that works

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply