Skip to content

Instantly share code, notes, and snippets.

@aliaspooryorik
Last active April 13, 2018 13:10
Show Gist options
  • Save aliaspooryorik/4c83435594bfaa197d80b39d16642c10 to your computer and use it in GitHub Desktop.
Save aliaspooryorik/4c83435594bfaa197d80b39d16642c10 to your computer and use it in GitHub Desktop.
query group count
<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