Path: dp-news.maxwell.syr.edu!spool.maxwell.syr.edu!drn.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!oleane.net!oleane!in2p3.fr!proxad.net!216.239.36.134.MISMATCH!postnews.google.com!g47g2000cwa.googlegroups.com!not-for-mail
From: norcold1@yahoo.com
Newsgroups: comp.databases.oracle.misc
Subject: SQl - Yes/No Grouping
Date: 11 Nov 2005 09:28:03 -0800
Organization: http://groups.google.com
Lines: 42
Message-ID: <1131730083.230820.36100@g47g2000cwa.googlegroups.com>
NNTP-Posting-Host: 162.119.240.102
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
X-Trace: posting.google.com 1131730088 20526 127.0.0.1 (11 Nov 2005 17:28:08 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Fri, 11 Nov 2005 17:28:08 +0000 (UTC)
User-Agent: G2/0.2
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322),gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: g47g2000cwa.googlegroups.com; posting-host=162.119.240.102;
   posting-account=yPlEag0AAACvrYP_XIhbOsTIDe24bpYS
Xref: dp-news.maxwell.syr.edu comp.databases.oracle.misc:123273

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'

