Solved

Adding Up Columns

Posted on 2002-07-23
11
124 Views
Last Modified: 2013-12-24
I need to add up columns of numbers from a query..  I do have it adding up but its adding up wrong.  Is there a way to zero out the number to make sure that is adding correctly or can someone give me a better solution for adding columns of numbers.. Here is my current query:

<cfquery name="getTotals" datasource="#DataTables#">
Select
     SUM(NetAmount) AS NetAmountTotal,
     SUM(ActualPages) AS ActualPagesTotal,
     SUM(EquivPages) AS EquivPagesTotal,
     SUM(HonAd) AS HonAdTotal,
     SUM(ProgAd) AS ProgAdTotal
FROM AdPages
WHERE adpages.issue_id = #URL.ID# AND adpages.cancelled = 0
</cfquery>

Thanks
0
Comment
Question by:jeffmace
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 3
11 Comments
 
LVL 5

Expert Comment

by:CFXPERT
ID: 7172815
Actually I don't see any problems with using the SUM funciton like your doing.  When you say it's not adding these columns up correctly, how much is it off by.  Maybe there's some other criteria involved here.
0
 
LVL 5

Accepted Solution

by:
CFXPERT earned 200 total points
ID: 7172922
Are you sure that all the data in the columns are valid numbers?  That would be one thing to check out.  I don't see how they couldn't be cause the database wouldn't let you insert a value that could not be converted to a number if the datatype is number.
0
 
LVL 17

Expert Comment

by:anandkp
ID: 7173441
Hi Jeffmace,

Pls chk ur

1. datatype
2. data [null / decimals / long values - might get truncated ]
3. Try using caste / convert function to get thru with this.

the above should help.

K'Rgds
Anand
0
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 

Author Comment

by:jeffmace
ID: 7174248
Acutally what I found out late last night was that it was a query problem with my INNER JOINS that were causing the issue...  I corrected it
0
 
LVL 5

Expert Comment

by:CFXPERT
ID: 7178282
I don't see any INNER joins in your posted SQL at the top of this forum.  We were trying to help you based on what you posted.

:) KWK
0
 
LVL 17

Expert Comment

by:anandkp
ID: 7179311
Hi Jeffmace,

I fully agree to what CFXPERT has posted above ... the help given is on the basis of what u ask on the site - as we have no clue whatsoever - the actual problem is ...

K'Rgds
Anand
0
 

Author Comment

by:jeffmace
ID: 7180003
Sorry if i didn't explain clearly... What I found out from the problem of the user was that the total was adding fine but it wasn't displaying all the records about it... for this example it was suppoed to have 15 records adding up to a total... well the total was correct but it was displaying only 13 records.

So I have a query above this that displays the records and then this query adds the records.
0
 

Author Comment

by:jeffmace
ID: 7180006
If either or you want to argue out who gets the points i will be more than happy to distribute them..
0
 
LVL 17

Expert Comment

by:anandkp
ID: 7180048
Hi Jeff,

Since u have to award point to someone - award it to the person whom u think - was closests to the answere ...

As i dont think we guys would want to argue out on this !!!

So its upto U !!!

K'Rgds
Anand
0
 

Author Comment

by:jeffmace
ID: 7180052
Thanks for your help
0
 
LVL 5

Expert Comment

by:CFXPERT
ID: 7180147
Not a problem jeff.  Just make sure that when you post questions try to be as exact as possible.  If you feel that you may know where the problem might be then make sure post all the code needed by us to help you out.

Thanks for the points.

:) KWK
0

Featured Post

Database Solutions Engineer FAQs

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller single-server environments.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question