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
Solved

Adding Up Columns

Posted on 2002-07-23
11
119 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 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
Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

 

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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

808 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