If I have the following query:

 

Column1 || Column2

  ValueA ||   ValueX

  ValueA ||   ValueY

  ValueB ||   ValueX

  ValueB ||   ValueY

  ValueB ||   ValueZ

 

 

And I want to turn the second column into a list, while keeping the first column unique - like so:

 

Column1 || Column2

  ValueA ||   ValueX, ValueY

  ValueB ||   ValueX, ValueY, ValueZ

 

 

Is there a more efficient way to do this than:

 

<cfoutput query="QueryXXX" group="Column1">

 

            <!--- populate groups list --->

            <cfoutput>

                        <cfset ColumnToList=listappend(ColumnToList,Column2) />

            </cfoutput>                   

 

            <!--- add row to final query --->

            <cfscript>

                        queryaddrow(FinalQuery);

                        querysetcell(FinalQuery,'Column1', Column1);

                        querysetcell(FinalQuery,'Column2', ColumnToList);

            </cfscript>

</cfoutput>

 

I’m sure there’s a million ways to do this…

 

Baz

 

 

 

 

 

----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com).

An archive of the CFCDev list is available at www.mail-archive.com/[email protected]

Reply via email to