Skip to main content
Inspiring
September 2, 2009
Question

SUM a SUM

  • September 2, 2009
  • 3 replies
  • 844 views

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 has been closed for replies.

3 replies

Inspiring
September 8, 2009

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.

Inspiring
September 2, 2009

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"])

djkhalifAuthor
Inspiring
September 2, 2009

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

djkhalifAuthor
Inspiring
September 2, 2009

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