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

Sum Loop over Group

Explorer ,
Nov 28, 2006 Nov 28, 2006

Copy link to clipboard

Copied

Hi,

I am trying to group a query and loop over and output hours summed. I attached the caode and an image of the results.
Any help will be greatly appreciated.
Thank you,
-R
TOPICS
Advanced techniques

Views

296

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

correct answers 1 Correct answer

Advisor , Dec 05, 2006 Dec 05, 2006

Forget about the array math.

Use this kind of logic:

Votes

Translate

Translate
LEGEND ,
Nov 28, 2006 Nov 28, 2006

Copy link to clipboard

Copied

Do you know how to select aggregates, such as count, sum, min, max, and avg in sql? All that works either in your original query, or with query of queries.

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
Advisor ,
Nov 28, 2006 Nov 28, 2006

Copy link to clipboard

Copied

The second sum is off because the counter is initialized in the wrong place.

Move <CFSET counter = 0> to just before the second <CFOUTPUT> tag.

Then get rid of these lines:

<CFLOOP QUERY="project_hours" STARTROW="#NewCount#" ENDROW="#CURRENTROW#">
<CFSET counter = counter + #Hours#>
</CFLOOP>

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
Explorer ,
Dec 04, 2006 Dec 04, 2006

Copy link to clipboard

Copied

Thank you MikerRoo - As soon as I read your message it made perfect sense. The sum of total hours across all projects works - I am multiplying the rate X Hours and I get the Project totals and this works However I am trying to sum all of the Project totals and this is not working.

The total should be 4375 however it is returning 3140 it is off by 1235. Any help would be greatly appreciated.

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
Advisor ,
Dec 05, 2006 Dec 05, 2006

Copy link to clipboard

Copied

LATEST

Forget about the array math.

Use this kind of logic:

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