Solved

Adding Up Columns

Posted on 2002-07-23
11
121 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
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.

 

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

756 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