By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,996 Members | 892 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,996 IT Pros & Developers. It's quick & easy.

Getting the sum of two fields from a view

P: 21
I am new to php and mysql and was just introduced to the use of view.
I have a view from two table and i need to sum up two fields from the view. Please help me in achieving this.

I need to get the sum of statement.cscs and clients.cscs (one for every client)

Expand|Select|Wrap|Line Numbers
  1.  
  2.   SELECT clients.cscs as cscs, clients.fname as fname, clients.lname as lname, 
  3.   clients.address as address, clients.emailad as emailad, clients.phone as phone, 
  4.   statement.transdate as tdate, statement.narration as narration, statement.debit as debit, 
  5.   statement.credit as credit FROM clients, statement where clients.cscs = statement.Cscs;
  6.  
  7.  
  8.  
Jun 3 '11 #1
Share this Question
Share on Google+
1 Reply


code green
Expert 100+
P: 1,726
SUM is used to sum the rows of a field.
You need to add....
Expand|Select|Wrap|Line Numbers
  1. (statement.cscs + clients.cscs) CSCS
Jun 6 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.