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 -> distinct on a union query.

distinct on a union query.

From: RickD. <rick_at_NOSPAMMEcanada.com>
Date: Thu, 17 Jan 2002 10:03:44 -0500
Message-ID: <hJB18.95240$Z2.1351253@nnrp1.uunet.ca>


Hi folks,

Can anyone help me?

I'm trying to do a Select Distinct on this UNION query WHILE keeping the original ORDER.

This:
SELECT org.org_id, '1' || do.opp_doc_no AS Ord FROM document_order do, opportunity_document od,

    order_basket ob, document_distributor dd,     organization org
WHERE do.order_no = '1774021' AND do.doc_qty > 0 AND

    od.opp_no = do.opp_no AND
    od.buyer_cont_no = do.buyer_cont_no AND UNION
SELECT org.org_id, '2' || ao.opp_att_no AS Ord FROM attachment_order ao, opportunity_attachment oa,

    order_basket ob, attachment_distributor ad,     organization org
WHERE ao.order_no = '1774021' AND ao.attmt_qty > 0 AND

    oa.opp_no = ao.opp_no AND
    oa.buyer_cont_no = ao.buyer_cont_no AND ORDER BY Ord ASC

returns:
60006 10
123456 11
32123 22
60006 21

What I want:
60006 (actually the record with the 10 in it) 123456
32123

TIA Rick. Received on Thu Jan 17 2002 - 09:03:44 CST

Original text of this message

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