Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2015
    Posts
    2

    Unanswered: Select Clause Query Help?

    Hey guys,

    brand new to SQL and have a question. In the select statement I wanted to select either PO_NOTTOEXCEED_VALUE if the PO_SUBTYPE is 'BO' or just select PCOM_VALUE_THISREV for all other PO_SUBTYPEs. You can see my SQL below:


    Code:
    SELECT PO_HEADERS.PO_SEQNO, 
    PO_HEADERS.PO_NUMBER, 
    PO_AWARD, 
    POCL_VTYV_VALUE, 
    (IF PO_SUBTYPE = 'BO'
    THEN PO_NOTTOEXCEED_VALUE, PCOM_VALUE_THISREV), 
    PCOM_NEGOTIATED_SAVING, 
    PCOM_REVNO 
    FROM PO_CLASSES, PO_HEADERS, PROJECT_COMMITMENTS 
    WHERE     POCL_PO_SEQNO = PO_HEADERS.PO_SEQNO 
    AND PCOM_DATASEQNO = PO_HEADERS.PO_SEQNO 
    AND POCL_VTYV_VALUE = 'OBE'
    AND PO_AWARD >= ADD_MONTHS (TRUNC (SYSDATE, 'MM'), -12)
    AND PO_AWARD < ADD_MONTHS (TRUNC (SYSDATE, 'MM'), 1)
    AND PCOM_REVNO = 0 
    AND PO_SUBTYPE <> 'REL'
    GROUP BY PO_HEADERS.PO_SEQNO, 
    PO_HEADERS.PO_NUMBER, 
    PO_RELEASE_NUMBER, 
    PO_AWARD, 
    POCL_VTYV_VALUE, 
    PCOM_VALUE_THISREV, 
    PCOM_NEGOTIATED_SAVING, 
    PCOM_REVNO;


    The select statement is where my code lies. Any ideas? Thanks.

  2. #2
    Join Date
    May 2015
    Posts
    1

    Hy

    You could use decode function. If i had been understand correct your problem.

  3. #3
    Join Date
    Jun 2004
    Posts
    796
    Provided Answers: 1
    90% of users' problems can be resolved by punching them - the other 10% by switching off their PCs.

Posting Permissions

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