Created
December 14, 2017 09:44
-
-
Save anonymous/79f6523d19efe6dcdb4da8872c1c2721 to your computer and use it in GitHub Desktop.
TryCF Gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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