Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Returning results in the order they were entered
"Niall Litchfield" <n-litchfield_at_audit-commission.gov.uk> schrieb im
Newsbeitrag news:3fabab68$0$261$ed9e5944_at_reading.news.pipex.net...
> > select distinct id,name from Caseflow.cases where number1 in
> > (124125,124122,124130);
> As others have said you need to define what you mean by 'order they were
> entered by the user', but you seem to mean
> in the order that appears in the in clause...
You can achive this with the disadvantage of an overhead. Use the UNION clause and split up the IN clause like this:
SELECT DISTINCT id, name, 1 idx from Caseflow.cases where number1 = 124125
UNION
SELECT DISTINCT id, name, 2 idx from Caseflow.cases where number1 = 124122
UNION
SELECT DISTINCT id, name, 3 idx from Caseflow.cases where number1 = 124130
...
ORDER BY idx;
-- Matthias Wirtz - Norfolk, USAReceived on Tue Nov 11 2003 - 20:24:51 CST