Last active
April 13, 2018 13:10
-
-
Save aliaspooryorik/4c83435594bfaa197d80b39d16642c10 to your computer and use it in GitHub Desktop.
query group count
This file contains hidden or 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> | |
foo = queryNew( | |
"id,name,group", | |
"Integer,Varchar,varchar", | |
[ | |
[1,"One", "A"], | |
[2,"Two", "A"], | |
[3,"Three", "B"], | |
[4,"Four", "C"], | |
[5,"Five", "C"], | |
[5,"Six", "C"] | |
] | |
); | |
choo = foo.reduce(function(previous, row) { | |
previous[row.group] = previous.keyExists(row.group) ? previous[row.group]+1 : 1; | |
return previous; | |
}, {}); | |
writeDump(choo); | |
</cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment