This topic is locked

How to sum a field

1/15/2009 4:41:53 AM
PHPRunner General questions
S
swanside author

Hello.

I want to get the SUM of the Loss field and display it, Can this be done?
It is to calculate how much weight somebody losses, as you can imagine, the Loss could also be a gain at some weeks?
Thanks

Paul.

SELECT

weights.Full_Name,

weights.`Date`,

weights.Weight,

members.Start_Weight,

(select Weight-Start_Weight) AS Loss

FROM weights

LEFT OUTER JOIN members ON weights.Full_Name = members.Full_Name
J
Jane 1/15/2009

Hi,
here is a sample:

SELECT

weights.Full_Name,

weights.`Date`,

weights.Weight,

members.Start_Weight,

sum(Weight-Start_Weight) AS Loss

FROM weights

LEFT OUTER JOIN members ON weights.Full_Name = members.Full_Name

Group By weights.Full_Name