• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

group function in coldfusion

New Here ,
May 04, 2007 May 04, 2007

Copy link to clipboard

Copied

Hello does anyone know how to use the group function in coldfusion
my tables that out-puts to a html
is outputing multiple CEENO

for example CEENO
11111
11111
11111
11111

someone here said to use the group function in coldfusion
do you know where i can put it?




<table border="2" cellpadding="2" cellspacing="0">
<tr>
<th>Record Number</th>
<TH>PEA_id</TH>
<th width="120">CEENO</th>
<TH>Address</TH>

<TH>ZipCode</TH>

<th>AdvisoryDate</th>






</tr>

<cfloop query="getthecases">


<tr bgcolor="<cfif currentrow mod 2>GHOSTWHITE<cfelse>WHITE</cfif>">
<td>#CurrentRow#</td>
<td>#PEA_id</td>
<Td>#CEENO#</td>
<td>#ST_NO# #ST_initial# #st_dir#</td>
<td>#ZipCode#</td>





<td>#dateformat(ADVISORY_DATE,"mm/dd/yyyy")#</td>









</tr>
</cfloop>

</table>
TOPICS
Advanced techniques

Views

352

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
May 04, 2007 May 04, 2007

Copy link to clipboard

Copied

The Group functionality built into the <Cfoutput> tag works something like this:

<!--- CFOUTPUT LOOP 1 (UNIQUE VALUES OF colA) --->
<cfoutput query="myQuery" group="colA">
<p>#colA#</p>

<!--- CFOUTPUT LOOP 2 (all records associated with unique ColA value)
<cfoutput>
#colB#
</cfoutput>

</cfoutput>

The outer cfoutput block (the one with the group="" attribute) will loop once for every unique value of the column you specify in the group attribute (assuming the values are ordered by ColA). The inner <cfoutput> block will loop for each row in the table that match that unique value of ColA.

TABLE:
ColA, ColB, ColC
A, 1, 0
A, 2, 0
B, 0, 0
C, 3, 1

Using the code above, you would see an output like this:

<p>A</p>
1
2
<p>B</p>
0
<p>C</p>
3

Hope that helps illuminate the problem. The official CF documentation can probably give you a little more indepth explaination.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 05, 2007 May 05, 2007

Copy link to clipboard

Copied

is this similar to group by in sql?

eliminating redunacies right?


where in my code should this be group be in. ?

Thanks

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 05, 2007 May 05, 2007

Copy link to clipboard

Copied

quote:

Originally posted by: silviasalsa
is this similar to group by in sql?

eliminating redunacies right?

Thanks

wrong

The group by clause in sql is used in conjunction with aggregates, like count, sum, etc. The group attribute in cfquery enables you fine tune the way you display your data.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 06, 2007 May 06, 2007

Copy link to clipboard

Copied

thanks
how and where do i place the group function on my code below?

<table border="2" cellpadding="2" cellspacing="0">
<tr>
<th>Record Number</th>
<TH>PEA_id</TH>
<th width="120">CEENO</th>
<TH>Address</TH>

<TH>ZipCode</TH>

<th>AdvisoryDate</th>






</tr>

<cfloop query="getthecases">


<tr bgcolor="<cfif currentrow mod 2>GHOSTWHITE<cfelse>WHITE</cfif>">
<td>#CurrentRow#</td>
<td>#PEA_id</td>
<Td>#CEENO#</td>
<td>#ST_NO# #ST_initial# #st_dir#</td>
<td>#ZipCode#</td>





<td>#dateformat(ADVISORY_DATE,"mm/dd/yyyy")#</td>









</tr>
</cfloop>

</table>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 06, 2007 May 06, 2007

Copy link to clipboard

Copied

LATEST
There is no group function. There is a group attribute in cfoutput. You are using cfloop instead of cfoutput so it wouldn't apply.

You have also not explained what it is you want to group and why. Those are rather significant details.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation