close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

How do you sum column values on a results page after a search query?

Thread began 10/28/2013 7:14 pm by ninetyplus | Last modified 11/05/2013 11:15 am by ninetyplus | 2660 views | 6 replies |

ninetyplus

How do you sum column values on a results page after a search query?

I have a page that stores client contracts and need to be able to sum numeric data on specific columns after a search query on the results page. This would be similar results to the total records found after a search (a basic dreamweaver function). Please let me know if you can assist. I've included my results page with the search form within the same page.

Thanks.

Sign in to reply to this post

Jason ByrnesWebAssist

use the SUM function in your query:

http://www.tutorialspoint.com/mysql/mysql-sum-function.htm

Sign in to reply to this post

ninetyplus

Thanks Jason. The problem I'm encountering is when I add a SUM function, it only returns 1 record. If I add a GROUP BY function such as the contract ID (npc_id), It doesn't SUM up the column values like my bag quantities (bag_qty). I attached the file I'm working on to the previous post but here is my SQL statement for the recordset I'm looking to get SUM results on.

"SELECT *,SUM(bag_qty) as TotalBags, (bag_qty*bag_weight) as TotalKg, (landed_price*2.2046) as KGprice, (bag_qty*bag_weight*2.2046*landed_price) as TotalContractPrice, Coalesce((twenty_five_paid_ci+spot+seventy_five),0) as BalanceDue FROM npc_contract LEFT OUTER JOIN clients ON npc_contract.client_id=clients.ClientID LEFT OUTER JOIN inventory ON npc_contract.coffee_id=inventory.inventory_id LEFT OUTER JOIN warehouse ON npc_contract.destination_port=warehouse.WarehouseID LEFT OUTER JOIN np_agents ON npc_contract.agent=np_agents.agentID WHERE inventory_year >= '2013' ORDER BY npc_id DESC"

The example above is just testing the SUM function of the bag quantites: SUM(bag_qty) as Total Bags. What I want to be able to do is sum the total values of certain columns after I have preformed a search.

Thanks Jason.

Sign in to reply to this post

Jason ByrnesWebAssist

yes, the sum function will only return the one sum result.

I would use 2 recordsets, one with the sum function, and a second with the other information in it.

Sign in to reply to this post

ninetyplus

Makes sense. One more question. If I'm performing a search and want to show the results of the search with both recordsets, how do I search them at the same time?

Thanks!

Sign in to reply to this post

Jason ByrnesWebAssist

2 instances of data assist search, one for the first recordset, the second for the second recordset.

Sign in to reply to this post

ninetyplus

Great. I'll give it try. Thanks for your quick response.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...