Re: oracle sql newbie question

From: Tom Grenier <tom_at_sqlman.com>
Date: Sun, 11 Mar 2001 10:01:50 -0500
Message-ID: <3AAB935E.90A06A38_at_sqlman.com>


Tom,

If you don't add an ORDER BY clause a query result can be in any order (by definition). The exact same query run twice can (although rarely does) return different order.

Just add an ORDER BY clause to your query.

Tom

xgong wrote:

> I appreciate if somebody help me with following question.
>
> Why following two statements give different order?
>
> SQL> select * from orders
> 2 where (prod_id, cust_id ) in
> 3 (select prod_id, cust_id from orders)
> 4 /
>
> ORD_DATE PROD_ID CUST_ID QUANTITY PRICE DISCOUNT
> --------- ---------- ------- ---------- ---------- ----------
> 20-FEB-00 1001 B0134 25 2065.85 50
> 20-FEB-00 1001 B0135 3 247.9 6
> 20-FEB-00 1741 B0134 5 65.5
>
> SQL> select * from orders
> 2 /
>
> ORD_DATE PROD_ID CUST_ID QUANTITY PRICE DISCOUNT
> --------- ---------- ------- ---------- ---------- ----------
> 20-FEB-00 1741 B0134 5 65.5
> 20-FEB-00 1001 B0134 25 2065.85 50
> 20-FEB-00 1001 B0135 3 247.9 6
>
> Thank you in advance,
>
> Tom Gong
Received on Sun Mar 11 2001 - 16:01:50 CET

Original text of this message