Algebra

  • Hello all,
    i would like to reach out to everyone for some guidance on how to best perform calculate an answer using algebra.

    Example here: https://www.tiger-algebra.com/drill/(27.839_32.72_a)/3=30.544/

    I'm not sure if TSQL can even do this using a function or if i need to leverage SQL R? any ideas?

  • Not that you can't do computation in T-SQL, but if you're looking to put formulas into columns and expect solutions, I'd have to question your judgment skills.   That kind of application makes far more sense as an application than an exercise for T-SQL.  I'm not going to visit that site.   I have no clear picture without it of what you hope to accomplish, and I'd rather NOT visit the site.   Surely you can explain what your overall objective is without having to re-direct people to another site...   Color me skeptical of those kinds of links...

    Steve (aka sgmunson) 🙂 🙂 🙂
    Rent Servers for Income (picks and shovels strategy)

  • Thanks for your reply. To clarify i'm not looking to put formulas into columns...I appreciate your concern with other sites.

    The goal is to provide a row with 4 columns to [x] and after the calculation is completed it would return the value for the column that would not have a value. I thought using a scalar function and was curious if that was the correct method.

    example below:
    Min, Max, Estimate, Result
    27.839, 32.72, a, 30.544
    expected result for example
    a = 31.073

    The link I provided is a method that could be used to calculate this using Algebra, ergo my question. I'm not sure what options i would have to tackle this kind of task. Alternatively I can find a simpler calculation that doesn't require the complex logic but I thought i would ask to see if anyone else had to go down that path.

  • cs_source - Wednesday, April 25, 2018 2:44 PM

    Thanks for your reply. To clarify i'm not looking to put formulas into columns...I appreciate your concern with other sites.

    The goal is to provide a row with 4 columns to [x] and after the calculation is completed it would return the value for the column that would not have a value. I thought using a scalar function and was curious if that was the correct method.

    example below:
    Min, Max, Estimate, Result
    27.839, 32.72, a, 30.544
    expected result for example
    a = 31.073

    The link I provided is a method that could be used to calculate this using Algebra, ergo my question. I'm not sure what options i would have to tackle this kind of task. Alternatively I can find a simpler calculation that doesn't require the complex logic but I thought i would ask to see if anyone else had to go down that path.

    If for every row in a given table with the columns you mentioned, you calculate a result, adding a scalar function is just going slow you down with function call overhead.   You would be better off just coding the computation for the new column in your query, or potentially as a COMPUTED column that is PERSISTED.   If you can post a CREATE TABLE statement for the table as you envision it, and then the INSERT statements for some sample data, and the expected results along with the details of the calculation, someone can easily respond with the exact query.

    Steve (aka sgmunson) 🙂 🙂 🙂
    Rent Servers for Income (picks and shovels strategy)

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

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