We Recommend

SQL Cookbook SQL Cookbook
Written in O'Reilly's popular Problem/Solution/Discussion style, the SQL Cookbook is sure to please. Anthony's credo is: "When it comes down to it, we all go to work, we all have bills to pay, and we all want to go home at a reasonable time and enjoy what's still available of our days." The SQL Cookbook moves quickly from problem to solution, saving you time each step of the way.


Posted By

mafro on 04/23/07


Tagged

random sorting


Versions (?)


Sort by random character


Published in: SQL 


Sort a result set by a random letter - this example uses the alphabet and a column named 'text'

  1. ORDER BY case when LEFT([text], 1) >= CHAR(65 + 26 * rand()) then 0 else 1 end

Report this snippet 

Comments

RSS Icon Subscribe to comments
Posted By: Davidhref on August 23, 2007

mafro this is good stuff thanks. This is useful for much more than sorting.

You need to login to post a comment.