Mathematical Functions in SQL

  • Im am trying to rewrite a vba Function into T-SQL

    I have a math calculation in vba which correctly calculates

    (1 - 1.5 * (0.11852 - 0.05478 * Log((3.00/ 10000))) ^ 2)

    to 0.524748374189154

    I cant get it to work in sql, Ive currently at

    power(1 - 1.5 * (0.11852 - 0.05478 * Log((3.00/ 10000))) ,2)

    which gives a different answer.

    Am I doing something wrong?

  • sanjsharma (2/18/2010)


    Im am trying to rewrite a vba Function into T-SQL

    I have a math calculation in vba which correctly calculates

    (1 - 1.5 * (0.11852 - 0.05478 * Log((3.00/ 10000))) ^ 2)

    to 0.524748374189154

    I cant get it to work in sql, Ive currently at

    power(1 - 1.5 * (0.11852 - 0.05478 * Log((3.00/ 10000))) ,2)

    which gives a different answer.

    Am I doing something wrong?

    select power(1 - (1.5 * ((0.11852 - 0.05478) * Log((3.00/ 10000)))) ,2)

    returns

    3.15262155946613

    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    This thing is addressing problems that dont exist. Its solution-ism at its worst. We are dumbing down machines that are inherently superior. - Gilfoyle

  • Thanks for your reponse.

    Ive worked it out now, I had the power in the wrong place

    it shouls have been

    select (1 - 1.5 * power((0.11852 - 0.05478 * Log((3.00 / 10000))) ,2))

    Thanks

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

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