erikjan Posted January 15, 2007 Share Posted January 15, 2007 Can someone please help me. Thank you very much in advance!I have a database with sold items. One of the many fields ina table for each sold item is shipping costs, another one the amount of that product sold.Imagine at a particular moment there are 80 rows inserted: client 1, client 2 etc. Each of themhas bought a certain amount of product A and/or B.What I would like to do is to calculate the total sum of product A sold in one month, plus thetotal amount of all shipping costs.Can someone please help me, how to do this after I have made the SQL query? Link to comment https://forums.phpfreaks.com/topic/34248-calculating-the-sum-of-table-fields/ Share on other sites More sharing options...
utexas_pjm Posted January 15, 2007 Share Posted January 15, 2007 Don't make things harder on yuorself. Calculate these values in the SQL:[code]SELECT COUNT(*) as products_sold, SUM(amount) as amount_soldFROM `your_table`WHERE `client` = 'xxx'[/code]Best,Patrick Link to comment https://forums.phpfreaks.com/topic/34248-calculating-the-sum-of-table-fields/#findComment-161091 Share on other sites More sharing options...
erikjan Posted January 15, 2007 Author Share Posted January 15, 2007 Thank you very much Patrick! Link to comment https://forums.phpfreaks.com/topic/34248-calculating-the-sum-of-table-fields/#findComment-161126 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.