Divide using formula from different table in sql

  • I need to evaluate a formula in sql server 2008

    Table 1 contains

    Entity Value

    A 2424053.500000

    B 1151425.412500

    C 484810.700000

    Table 2 contains

    Entity Formula

    A (2100*(1-0.0668)*24*mday*10)

    B (1000*(1-0.0575)*24*mday*10)

    C (1260*(1-0.09)*24*mday*10)

    Where mday is number of days taken from user

    I need to calculate the output of value/formula for each entity can you provide me the query for the same

    The datatype for formula column is varchar

    I do not have the liberty to use cursors or loops.mday will be a input fromt the user say 'mday = 31' ..i need to divide the value in the first table with the computed value of the formula after replacement

  • Storing the formula as a string is asking for trouble and it setting you up for an impossible challenge.

    As I look at the formulas, there are only three values changing:

    (2100*(1-0.0668)*24*mday*10)

    I would store these 3 values in seperate columns. In that case it's much easier to calculate the formula.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

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

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