Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> SQl - Yes/No Grouping

SQl - Yes/No Grouping

From: <norcold1_at_yahoo.com>
Date: 11 Nov 2005 09:28:03 -0800
Message-ID: <1131730083.230820.36100@g47g2000cwa.googlegroups.com>


Looking for some SQL help.

I have a query which pulls from a header / detail table looking for certain type codes. That works fine.

But I want to return a yes or no for the entire order if the subcode exists.
For the example, below I get 3 Records

503512210,911
503512210,600
503512210,705

So I would like to have the query instead return

503512210,True

because 911 is in the results

for order
551250,912
551250,600

551250, False

because 911 isn't in the results. Is this possible?

SQL so far:


SELECT
  PCH.ORDER_NUMBER
FROM
  ORDER_HEADER PCH,
  ORDER_DETAIL PCD
WHERE
  PCH.SEQ_ORDER_ID = PCD.SEQ_ORDER_ID AND   (PCD.TYPE_CODE = '911' OR
  PCD.TYPE_CODE NOT BETWEEN '921' AND '999') AND   PCH.ORDER_NUMBER='503512210' Received on Fri Nov 11 2005 - 11:28:03 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US