Simple Query I Need.....

  • SELECT EXP(SUM(LOG(SID))) FROM #t

    I don't understand how this actually works. We getting the float value of all the numbers and then converting it into an exponential value. Sorry guys, looks past my ignorance for a second. Are we then saying that the sum of two natural logarithm values is equal to multiplying them? Snap, this could be extremely handy. I would have gone the dynamic SQL route probably, I am curious though to see the dynamic SQL that Sandy used in the first attempt. Reading forums is enlightening. Thanks guys.

  • It's a property of logarithms.

    Edit: My maths stinks. So out of practice.

    e(ln(x) + ln(y)) = x * y for all values of x and y

    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
  • the mighty BOL states :

    Remarks EXP

    The constant e (2.718281…), is the base of natural logarithms.

    The exponent of a number is the constant e raised to the power of the number.

    For example EXP(1.0) = e^1.0 = 2.71828182845905 and EXP(10) = e^10 = 22026.4657948067.

    The exponential of the natural logarithm of a number is the number itself: EXP (LOG (n)) = n.

    And the natural logarithm of the exponential of a number is the number itself: LOG (EXP (n)) = n.

    Remarks LOG

    The constant e (2.71828182845905…) is the base of natural logarithms.

    The base of natural logarithms is the constant e (2.71828182845905…).

    LOG ( e ) = 1.0.

    The natural logarithm of the exponential of a number is the number itself: LOG( EXP( n ) ) = n.

    And the exponential of the natural logarithm of a number is the number itself: EXP( LOG( n ) ) = n.

    I knew there must have been a purpose for all those hours of math +20 years ago :w00t:

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

  • Crisis, this is getting confusing, yet inspires me to go and find more of these wierd, but usefull, functions. Thanks for the insight guys.

  • Hey Sandy,

    Sorry I'm late to the game, but everything Jeff said goes double for me. 😀

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • So - anyone up for a good round of sine/cosine/tangent/arctengent?

    Remember: SOHCAHTOA...

    Ahhh - high-school math....Nope - I still don't remember most of it@

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?

  • Sandy (1/17/2008)


    Hey sqluser,

    Thanks, It is working...

    Jeff,

    Actually I asked about this post...

    " http://www.sqlservercentral.com/Forums/Topic444141-338-1.aspx "

    Jeff,

    -------------

    Sandy learned nothing about what Sandy was supposed to learn... except how to cheat. Great job, Pal!

    he he he...lolz:hehe:

    Cheers!

    Sandy.

    So... I see you've adopted the answer that was not the intent of the question... you've learned nothing except, obviously, how to type "he he he". You've missed a prime learning opportunity by cheating and still getting the wrong answer for the question posed by your instructor... question was meant for you to study recurrsion... not to get the mathematically correct equation.

    You have no idea what you're doing to yourself...

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Hi Jeff,:hehe:

    Thanks for your suggestion.

    I will follow this..

    Thanks for the same...

    No more.....he he he..lolz...;):P:w00t::cool::hehe:

    Cheers!

    Sandy.

    --

  • We'll see... when you figure out the correct answer for the real question being asked, post it here.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 9 posts - 16 through 23 (of 23 total)

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