limitting the value

  • I am displaying percentages as a column in the stored procedure output. Sometimes the percentage is showing as 128% or 155% which is wrong. But is there any function to dispaly that as 100% in case if we have more percentage(greater than 100).

    Thanks.

  • You can use a case statement

    SELECT CASE WHEN Value > 100 THEN 100 ELSE Value END FROm SomeTable

    Can you post the query? Maybe someone can see something wrong with the calculation that's resulting in the > 100% values.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Thanks.

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

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