Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I count column values from a CFQUERY

Status
Not open for further replies.

tkt

Programmer
Dec 13, 2001
7
0
0
US
I have a query that returns multiple columns of numbers, for each column. I have 3 numbers 3, 4, 8 and I want to loop through the column_1, 3 times counting how many times 3, 4 and 8 appear, then column_2, 3 times.....etc.

So far my answer is to build a query for each column & then make an ArrayToList then ListValueCount (although I don't have it working yet). There must be some way to do this in one step.

Does anyone have any ideas?

TIA

 
I found the answer! It is: <cfset col_1_list = ValueList(get_ftn_survey.priority_1)>

where get_ftn_survey is the name of the original query and priority_1 is the name of the first column.

What is returned is a list of all the column data which I can run a listValueCount on <cfset col_1_count = ListValueCount(col_1_list, 1)> and I have my count without making the additional queries by column! :)

Can anyone get this into one line? So ListValueCount can see the ValueList directly from the query results?
 
You can nest the functions like:

ListValueCount(ValueList(get_fn_survey.priority_1), 1)

HTH,
Tim P,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top