Question : SQL ORDER BY

I have a written a query without putting an ORDER BY.

I noticed that every time I ran the query the order of the records would change.

I have now placed an ORDER BY in the query and the order is now the same every time it is run.

Is it normal for the order to change each time a query is executed if it does not have an ORDER BY?

Answer : SQL ORDER BY

ORDER BY clause - is used to order rows returned by the statement. Without an order_by_clause, no guarantee exists that
the same query executed more than once will retrieve rows in the same order.
Restrictions on the order_by_clause:
w If you have specified the DISTINCT operator in this statement, this clause cannot refer to columns unless they appear
in the select list.
w An order_by_clause can contain no more than 255 expressions.
w You cannot order by a LOB column, nested table, or varray.
Random Solutions  
 
programming4us programming4us