Results 1 to 5 of 5

Thread: script enquiry

  1. #1
    Join Date
    Aug 2005
    Location
    Kuala Lumpur, MY
    Posts
    108

    Unanswered: script enquiry

    guys i do have a question here..

    Code:
    SELECT record_date, rej_reason, SUM(NO_RECORD) 
    FROM md_rec_bscs 
    WHERE TO_DATE(record_date, 'dd/mm/RRRR') > TO_DATE('01/05/2007', 'dd/mm/RRRR')
    AND SWITCH_NAME = 'MMG1'
    AND SYSTEM_NAME = 'BSCS'
    AND REJ_REASON = 'rec out'
    OR REJ_REASON = 'rej Prepaid Record'
    GROUP BY record_date, rej_reason
    ORDER BY record_date ASC
    The above code is supposed to give me an output that shows the sum of records for rej_reason 'rec out' and 'rej Prepaid Record' from 01/05/2007 but what it returns is rej_reason 'rec out' from 01/05 and 'rej Prepaid Record' from the date is has from the table.. Why is it behaving this way... any idea ?

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    >Why is it behaving this way... any idea ?
    That is what you asked it to do.
    SQL returns what it was programmed to do.
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    Mar 2007
    Posts
    623
    Condition Precedence
    Use brackets, if you want to evaluate conditions in other precedence (eg. OR before AND).

  4. #4
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    In other words


    Code:
    SELECT record_date, rej_reason, SUM(NO_RECORD) 
    FROM md_rec_bscs 
    WHERE TO_DATE(record_date, 'dd/mm/RRRR') > TO_DATE('01/05/2007', 'dd/mm/RRRR')
    AND SWITCH_NAME = 'MMG1'
    AND SYSTEM_NAME = 'BSCS'
    AND (REJ_REASON = 'rec out'
    OR REJ_REASON = 'rej Prepaid Record')
    GROUP BY record_date, rej_reason
    ORDER BY record_date ASC
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

  5. #5
    Join Date
    Jul 2003
    Posts
    2,296
    should i mention if record_date is a DATE datatype then I wonder why you are then converting it to a date when it is already a date?
    - The_Duck
    you can lead someone to something but they will never learn anything ...

Posting Permissions

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