Avg Function Decimal Places

  • ay to display only 1 place after the decimal point any help is appreciated

    select

    Round(Avg(Cast(MatchAssessment.Mark as decimal(18,3))),1)

    from Match

    LEFT JOIN Teams on Match.ID = Teams.MatchID

    LEFT JOIN MatchAssessment on MatchAssessment.TeamID = Teams.TeamID

    LEFT JOIN Person on MatchAssessment.CoachId = Person.ID

    where Match.Date between '2005/7/1' and '2006/6/30'

    --and Person.ID = 11619

    and (Match.CompetitionID = -1 or -1 = -1)

    and Teams.PlayerID = 9

    And MatchAssessment.Mark is not null

    group by Person.ID

    these are the results i get

    5.200000

    5.400000

    .000000

    6.500000

    5.000000

    5.100000

  • Cast the result of the Round() function to DECIMAL(x,1), like this:

    SELECT Cast(Round(Avg(Cast(MatchAssessment.Mark as decimal(18,3))),1) AS Decimal(10,1)) AS MarkAvg

      FROM Match

     ...rest of query...

     

     

Viewing 2 posts - 1 through 1 (of 1 total)

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