Help with SQL Maths Operators

  • In SQL, ^ is a bitwise exclusive OR. You'll be wanting the POWER function.

    SELECT POWER(2,3) -- 8

    SELECT POWER(5,2) -- 25

    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 for the response, what do you mean use POWER? I'm not aware of that function.

    How would the code look ?

  • Roughly speaking, like the following (untested):

    SELECT MTG_QCA = CASE WHEN ttss_avgeqcapointscore < 1 THEN 0

    ELSE ROUND([LAT2011].[Gamma0] + [LAT2011].[Gamma1]

    * [ttss_avgeqcapointscore]

    + [LAT2011].[Gamma2]

    * POWER([ttss_avgeqcapointscore], 2)

    + [LAT2011].[Gamma3]

    * POWER([ttss_avgeqcapointscore], 3)

    + [LAT2011].[Gamma4]

    * POWER([ttss_avgeqcapointscore], 4), 2)

    END

    It's just a syntax difference

  • Knives85 (9/24/2013)


    Thanks for the response, what do you mean use POWER? I'm not aware of that function.

    The built-in system function POWER. If you're not familiar with it, look it up in Books Online.

    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

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

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