Skip to main content
Inspiring
March 14, 2008
Answered

cfpoutput query group

  • March 14, 2008
  • 3 replies
  • 500 views
I posted something like this previously and thought I got it to work, but not it does not work.
I have a table with state, cities within each state, and multiple codes for each city.

For each state, I want to list all the cities within each state alphabetically, and then the city codes and count for each city.

The output should look like this :

California
Los Angeles
1 (150)
4 (35)

San Diego
1 (350)
4(433)

San Francisco
1 (67)

etc...

This is what I am getting, using the code below :

California
Los Angeles
1 (150)
San Diego
1 (350)
San Francisco 1 (67)
Los Angeles
4 (35)
San Diego
4 (443)

<cfoutput query="qry" group="state">
<td valign="top">
<b>#state#</b>
<br>
<cfoutput group="city">
#city#
<br>
<cfoutput>
<cfif citgy_code is "4">
<a href="link goes here>#city_code# (#totalcount#)</a><br>
<cfelseif city_code is "1">
<a href="link goes here">#city_code# (#totalcount#)</a><br>
</cfif>
</cfoutput>
</cfoutput>
</td>
</cfoutput>

What do I need to do with the above code to group all of the cities together, listing all of the codes, instead of having the cities separated by the code ?

Thanks for any help.
    This topic has been closed for replies.
    Correct answer Dan_Bracuk
    The likely cause of your problem is the lack of an order by clause in your query.

    3 replies

    Dan_BracukCorrect answer
    Inspiring
    March 16, 2008
    The likely cause of your problem is the lack of an order by clause in your query.
    Inspiring
    March 15, 2008
    What's the query?
    trojnfnAuthor
    Inspiring
    March 15, 2008
    the query is somewhat complex (for me) and involves numerous views, so somebody else wrote it.

    I just need to know how to format the output properly, based on the code and example I provided. Do I have the table tags in the wrong area, or the cfoutput group in the wrong area ?
    Inspiring
    March 15, 2008
    What's the query?