Sponsored by NuSphere - PHP Software for PHP Application Developers - On Sale This Week for $100



Go Back   PHP-Editors > Linux, Apache, MySQL > MySQL Help

MySQL Help Post any question relating to MySQL here and hopefully someone can help

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 2006-05-08, 05:43 AM
Member
 
Join Date: Mar 2006
Posts: 32
shams
Exclamation Addition code for mysql?

hi,
how i can get the sum of the integers of one column?

Last edited by shams; 2006-05-08 at 03:57 PM.
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 2006-05-09, 10:15 PM
stuart's Avatar
Administrator
 
Join Date: Jan 2003
Location: Scotland
Posts: 472
stuart will become famous soon enoughstuart will become famous soon enough
Send a message via MSN to stuart
Default

Is it not just the count function? SELECT COUNT(field) FROM table
Reply With Quote
  #3 (permalink)  
Old 2006-07-24, 09:18 AM
Junior Member
 
Join Date: Jul 2006
Posts: 1
trevayne is on a distinguished road
Default hmm..

hello i guess i have a similar question regarding getting the sum of integers in one column.

well if youre going to use SELECT COUNT(FIELD) FROM TABLE . you can only get the number of data in that table or should i say the number of rows.

+----+--------+------------+------+
| id | c_code | date | peso |
+----+--------+------------+------+
| 74 | 10 | 1254-07-08 | 564 |
| 75 | 11 | 1235-05-06 | 23 |
| 78 | 4 | 1236-08-07 | 564 |
| 79 | 5 | 1254-07-08 | 564 |
| 82 | 12 | 1235-08-07 | 654 |
| 83 | 13 | 1245-05-06 | 321 |

well i have this table and i want to add the values all inside the peso column,
hmm heheeh and i cant quite get the proper query to perform.
tnx,.
Reply With Quote
  #4 (permalink)  
Old 2006-07-24, 11:38 AM
Senior Member
 
Join Date: Jul 2006
Location: Prague, Czech Republic
Posts: 193
vladimir_cz is on a distinguished road
Send a message via ICQ to vladimir_cz Send a message via MSN to vladimir_cz Send a message via Yahoo to vladimir_cz Send a message via Skype™ to vladimir_cz
Default

just add one calulated column with next way:
select peso, peso*1.2 as peso_with_tax from <table>

or just sum?
select sum(peso) from table where...
if need, add group by for calculate sums for each date, some code, etc.
__________________
Thank you. Vladimir, Czech Republic.
http://www.smartwebco.com/
I'm looking for job.
Reply With Quote
  #5 (permalink)  
Old 2006-07-25, 12:56 AM
Moderator
 
Join Date: May 2004
Location: Portugal
Posts: 143
gesf is an unknown quantity at this point
Send a message via ICQ to gesf Send a message via MSN to gesf Send a message via Skype™ to gesf
Default

Code:
SELECT SUM(peso) AS 'Real sum of field values';
For MySQL 5.0 users... use Triggers!
__________________
Best Regards,
Gonçalo "GesF" Fontoura

Website : gesf.org
Reply With Quote
  #6 (permalink)  
Old 2006-07-25, 02:10 AM
Xnuiem's Avatar
Senior Member
 
Join Date: May 2004
Location: DFW, Texas
Posts: 1,104
Xnuiem will become famous soon enough
Send a message via Yahoo to Xnuiem
Default

how would triggers help get the sum of a column?
__________________
I rarely give code examples.
No, I have never used IIS or Windows of any kind as a web server. Get a real OS!
Please don't PM me, I won't respond.
Reply With Quote
  #7 (permalink)  
Old 2006-07-25, 06:54 AM
Moderator
 
Join Date: May 2004
Location: Portugal
Posts: 143
gesf is an unknown quantity at this point
Send a message via ICQ to gesf Send a message via MSN to gesf Send a message via Skype™ to gesf
Default

Got it I ment the examples on that page.
__________________
Best Regards,
Gonçalo "GesF" Fontoura

Website : gesf.org
Reply With Quote
  #8 (permalink)  
Old 2006-07-26, 02:52 AM
Xnuiem's Avatar
Senior Member
 
Join Date: May 2004
Location: DFW, Texas
Posts: 1,104
Xnuiem will become famous soon enough
Send a message via Yahoo to Xnuiem
Default



You are trigger happy my friend!
__________________
I rarely give code examples.
No, I have never used IIS or Windows of any kind as a web server. Get a real OS!
Please don't PM me, I won't respond.
Reply With Quote
Must read Review for Serious PHP Developers


NuSphere PhpED 5.0 : The Staff of php-editors.com recently spent a few days working with NuSphere PhpED 5.0 (a popular PHP IDE) and NuCoder 1.4 (a PHP Encoding Utility), read up on all the details.

Sponsored Links
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 07:33 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.