Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2009
    Posts
    8

    Unanswered: Why does this sql return no results?

    hello,

    Can anyone tell me why this sql statement returns 0:
    I cant see anything wrong with it:

    Code:
    SELECT	
        SUM(TBL_RESULTS.FTBR_UNIT_QTY) AS TotalFailedQty,
        TBL_RESULTS.FTBR_OPERATION_GROUPING_UUID
    FROM
        UKCHAPP145.TBL_RESULTS
    WHERE
        TBL_RESULTS.FTBR_PASS_OR_FAIL = '0'
    AND
        TBL_RESULTS.FTBR_HEADER_UUID = 'F3256934-5056-9B56-8A234AD86A127514'
    GROUP BY
    	TBL_RESULTS.FTBR_OPERATION_GROUPING_UUID
    If i take out the:
    Code:
    WHERE
        TBL_RESULTS.FTBR_PASS_OR_FAIL = '0'
    It seems to work.

    Before anyone posts back there are 0 values in the FTBR_PASS_OR_FAIL COLUMN.

    Any help appreciated.

    jm

  2. #2
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    If by zero values you mean number 0 then

    Code:
    SELECT    
        SUM(TBL_RESULTS.FTBR_UNIT_QTY) AS TotalFailedQty,
        TBL_RESULTS.FTBR_OPERATION_GROUPING_UUID
    FROM
        UKCHAPP145.TBL_RESULTS
    WHERE
        TBL_RESULTS.FTBR_PASS_OR_FAIL = 0
    AND
        TBL_RESULTS.FTBR_HEADER_UUID = 'F3256934-5056-9B56-8A234AD86A127514'
    GROUP BY
        TBL_RESULTS.FTBR_OPERATION_GROUPING_UUID
    if you mean there is NO value in the column then

    Code:
    SELECT    
        SUM(TBL_RESULTS.FTBR_UNIT_QTY) AS TotalFailedQty,
        TBL_RESULTS.FTBR_OPERATION_GROUPING_UUID
    FROM
        UKCHAPP145.TBL_RESULTS
    WHERE
        TBL_RESULTS.FTBR_PASS_OR_FAIL is null
    AND
        TBL_RESULTS.FTBR_HEADER_UUID = 'F3256934-5056-9B56-8A234AD86A127514'
    GROUP BY
        TBL_RESULTS.FTBR_OPERATION_GROUPING_UUID
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

  3. #3
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Talking Nvl()=?

    Or maybe both:
    Code:
    -- Etc --
    WHERE
        NVL(TBL_RESULTS.FTBR_PASS_OR_FAIL,0) = 0
    -- Etc --
    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

  4. #4
    Join Date
    Jan 2009
    Posts
    8
    Hi Guys,

    Thank you for your replies,

    What i was trying to say was that nothing was being returned when it should have done.

    I eventually spotted the error of my ways and now its all working just fine.

    thanks

    jm

  5. #5
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    oh, please, don't torture us like that... what was the cause of the problem?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •