House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home / Groups / ColdFusion Talk (CF-Talk)

How can I "ORDER BY RANDOM" ?

Author:
Russ
04/03/2003 05:14 PM

If your database has a random number generator function, you can try: SELECT tblCompany.*, Random() as SortOrder FROM tblCompany ORDER by SortOrder HTH--haven't tried it myself. Russ > Dear CF'ers: > > I have searched my CF books for a clue, but am unable to find > an example of > what I am trying to do. > > I need to modify the below query so that my results are still > ordered by > "ClassOfService" (a number between 1 and 4) - BUT, the > "CompanyName" needs > to be displayed in a RANDOM ORDER each time the query is run, > rather than > its current alphabetical order. This will give all companies that > participate an even advantage of being selected rather than > those that > begin with the first letters of the alphabet. > > Can someone please point me in the right direction? I have > studied the CF > RANDOM tag but can't figure out how to apply it. > > <CFQUERY NAME="GetAllCompaniesWithMiniSites" DATASOURCE="MedMallDs" > DBTYPE="ODBC"> > >      SELECT * > >          FROM CompanyTbl > >          WHERE CompanyWantsMiniSite = 'Yes' AND > MakeMiniSitePublic = 'Yes' > >          ORDER BY CompanyTbl.ClassOfService, CompanyTbl.CompanyName > > </CFQUERY> > > Thanks very much!! > > Tom Forbes > > > > ************************************************************** > ********* > Tom Forbes,  Forbes Consulting, Inc. > TEL: 407-772-3427       FAX: 407-772-3428 > Visit www.medmatrix.com for Medical Equipment Web Sites! > E-Mail Subscription at www.medmatrix.com/mail_list.htm > ************************************************************** > ********* > >


Search cf-talk

May 18, 2013

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
       1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31   

Designer, Developer and mobile workflow conference