Skip to main content
Inspiring
May 29, 2009
Answered

Grouping database column output with separator

  • May 29, 2009
  • 1 reply
  • 542 views

Using Coldfusion MX 7 with SQL Server 2005.  I'm outputting the results from SQL Server in a table in which I want to group one of the columns with a separator between the like values, like so:

1  Bobby

1  Thomas

1  Jason

-----------------

2  Harold

2  George

----------------

5  Mark

5  Alex

5  Wes

I can group them fine, but my output normally just puts the separator at the end of the total results like so:

1  Bobby

1  Thomas

1  Jason

2  Harold

2  George

5  Mark

5  Alex

5  Wes

----------------

I know this is a simple solution, but I can't wrap my thoughts around it.

This topic has been closed for replies.
Correct answer ilssac

Nested <cfoutput....> tags.  You did not describe what columns are used for that display so I will just make them up.

<cfoutput query="aQry" group="aNumber">

  <cfoutput>

    #aNumber# #aName#<br/>

  </cfoutput>

  ----------

</cfoutput>

1 reply

ilssac
ilssacCorrect answer
Inspiring
May 29, 2009

Nested <cfoutput....> tags.  You did not describe what columns are used for that display so I will just make them up.

<cfoutput query="aQry" group="aNumber">

  <cfoutput>

    #aNumber# #aName#<br/>

  </cfoutput>

  ----------

</cfoutput>

LumpiaAuthor
Inspiring
May 29, 2009

Wow.  Can't believe I forgot about that extra set of <cfoutput> tags that perform that trick.  Thanks for the quick reply.  Worked great.