Random Sort Order in Oracle SQL, by Zahar Hilkevich

The easiest way to do random sorting in SQL is to use a function that returns different value every time it is invoked. In Oracle SQL, a function sys_guid() serves the purpose very well:

SELECT empno, ename, job, deptno
FROM emp
ORDER BY sys_guid()

sys_guid() is normally used to generate a GUID value in Oracle SQL.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s