Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Adding Up Columns

Posted on 2002-07-23
11
Medium Priority
?
126 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
  • 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 800 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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

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…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

877 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