power function

  • Hi

    I am new at SQL, so pls bear with me. How do I correct my code below

    select '1' [union] ,type,SHORTHAND,num,denom,[current],past,round([current]-past,1) current_past,

    round((2.0*num+power(3.0902,2)-3.0902*SQRT(power(3.0902,2)+4.0*num*(1-[current])))/(2.0*(denom+power(3.0902,2))),6) lower_l2,

    round((2.0*num+power(3.0902,2)+3.0902*SQRT(power(3.0902,2)+4.0*num*(1-[current])))/(2.0*(denom+power(3.0902,2))),6) upper_l2,

    Peer_Max,Peer_Min,quarter

    I keep getting this message Msg 3623, Level 16, State 1,A domain error occurred.

    Warning: Null value is eliminated by an aggregate or other SET operation.

  • write the complete query

  • niyinks (8/3/2010)


    Hi

    I am new at SQL, so pls bear with me. How do I correct my code below

    select '1' [union] ,type,SHORTHAND,num,denom,[current],past,round([current]-past,1) current_past,

    round((2.0*num+power(3.0902,2)-3.0902*SQRT(power(3.0902,2)+4.0*num*(1-[current])))/(2.0*(denom+power(3.0902,2))),6) lower_l2,

    round((2.0*num+power(3.0902,2)+3.0902*SQRT(power(3.0902,2)+4.0*num*(1-[current])))/(2.0*(denom+power(3.0902,2))),6) upper_l2,

    Peer_Max,Peer_Min,quarter

    I keep getting this message Msg 3623, Level 16, State 1,A domain error occurred.

    Warning: Null value is eliminated by an aggregate or other SET operation.

    Somewhere along the line, the value used for the power function is resulting either in a negative number or 0. You need to find that problem in the data and have your code compensate for that eventuality.

    --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)

  • where is the "from" clause of your query.

    if you want me to help you write the whole query.

    you see 'select ' query is in this form:

    Select a,b,c,... from tableName

  • Have a look at http://www.sql-server-performance.com/faq/domain_error_occurred_p1.aspx

    Try running your query with only the content of the SQRT i.e. power(3.0902,2)+4.0*num*(1-[current]) and see if you can identify the problem with yor data.

  • Ok

    I assume you have a null value in your database so it causes that

    aggregate functions to fail.the best and correct way is to use 'Isnull'

    function to eliminate null value the second and easy way is to

    use the following statement at the beginning of your query but the first way is better .

    set ANSI_WARNINGS OFF

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

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