Skip to content

Instantly share code, notes, and snippets.

Created December 14, 2017 09:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/79f6523d19efe6dcdb4da8872c1c2721 to your computer and use it in GitHub Desktop.
Save anonymous/79f6523d19efe6dcdb4da8872c1c2721 to your computer and use it in GitHub Desktop.
TryCF Gist
<cfscript>
/* Create an unsorted CF-query */
unsorted = QueryNew("col1,col2,col3,col4","VarChar,VarChar,Integer,VarChar");
for (a=10;a gte 1;a--){
QueryAddRow(unsorted);
QuerySetCell(unsorted,"col1","col1 #a#");
QuerySetCell(unsorted,"col2","col2 #a#");
QuerySetCell(unsorted,"col3","#a#");
QuerySetCell(unsorted,"col4","col4 #a#");
}
writeDump(var="#unsorted#");
/* Create a new CF query of query with the unsorted table */
sorted = new query(
dbtype = "query"
,unsorted = unsorted
,sql = "select [col1],[col2] from unsorted order by [col3], [col4] asc"
).execute().getresult();
/* The last column in the order by list will be displayed in the result */
writeDump(var="#sorted#", label="sorted");
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment