WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-20-2008, 12:08 PM
amkma amkma is offline
WebProWorld New Member
 

Join Date: Oct 2004
Location: London
Posts: 6
amkma RepRank 0
Default sum of sum

Hi everyone.
Good day.

I have a table 'payments' with 9 fields.
id,
client_name,
total_amount,
deposit_paid,
deposit_paid_on_date,
1st_installment,
installment_paid_on_date,
2nd_installment_paid,
2nd_installment_paid_on_date

I want to get the the sum of each payment, for which I have used the 'sum()' in the query.

But how can I get the sum of the sum (deposit_paid + 1st_installment + 2nd_installment) received today.

Regards.
Reply With Quote
  #2 (permalink)  
Old 03-20-2008, 01:38 PM
amkma amkma is offline
WebProWorld New Member
 

Join Date: Oct 2004
Location: London
Posts: 6
amkma RepRank 0
Default Re: sum of sum

I have tried these, But no luck.

$curdate=date("YmdHis");

$result=mysql_query("SELECT SUM(deposit_paid) AS depo + SUM(1st_installment) AS secpay + SUM(2nd_installment) AS thirdpay FROM payments WHERE deposit_paid_on_date = $curdate or installment_paid_on_date = $curdate or 2nd_installment_paid_on_date = $curdate");

OR

$result=mysql_query("SELECT SUM(deposit_paid + 1st_installment + 2nd_installment) AS totpay FROM payments WHERE deposit_paid_on_date = $curdate or installment_paid_on_date = $curdate or 2nd_installment_paid_on_date = $curdate");

while($row = mysql_fetch_array($result)){

echo "Total payments today= £ ". $row['totpay'];

}


where am I going wrong here? No error just doesnt display anything... Is this type of query even possible?
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum


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

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



Search Engine Friendly URLs by vBSEO 3.0.0