Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> distinct on a union query.
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