Skip to main content
Inspiring
Sep 2, 2009 2:41 PM UTC
Question

SUM a SUM

Good morning All,

I have an with SUM(tbl_Assembly_Production.UnitsProd) Total_Units. This returns a sum per record per date but, I need to sum that sum down to Totals. Is there an effect way to do this and output to Excel? I did try <cfset Totals = SUM(Total_Units)>

Thanks in Advance,

DJ Khalif

This topic is closed to new replies. Start a new post to keep the conversation going.

4 replies

Inspiring
Sep 8, 2009 1:55 PM UTC

You should do all of the sums and other summaries in an SQL query that references the appropriate table(s).  If you can't do the job in a single SELECT statement (I'll bet you can...) then you can use "subqueries" in SQL.

Let the database server do all of the hard work for you and send you only the results you need.  You don't want thousands or millions of records to "flow over the wire" just to be added-up.

Translate
Inspiring
Sep 2, 2009 4:46 PM UTC

If tbl_Assembly_Production is a cold fusion query object, you can use either Q of Q

     select sum (something) from etc

or ArraySum.

     x = arraysum(queryname["fieldname"])

Translate
djkhalifAuthor
Inspiring
Sep 2, 2009 6:49 PM UTC

Dan,

I'll give that a shot. I ran into something issues. Data Integrity!!!!!!!! No matter how hard you work at something, you will always find other ways to work harder at it......... To improve it no doubt.

Thanks,

DJ Khalif

Translate
djkhalifAuthor
Inspiring
Sep 2, 2009 3:00 PM UTC

Ok,

I am trying to resolve, I tried this <cfoutput>=SUM(C2:C11)</cfoutput> and, it works. But my table will grow as battery types are added. Any help?

Thanks,

DJ Khalif

Translate