how to subtract of two numbers in mysql

Solutions on MaxInterview for how to subtract of two numbers in mysql by the best coders in the world

showing results for - "how to subtract of two numbers in mysql"
Alberto
27 Jul 2018
1select sum(s0.w - s1.w) as total_weight_loss
2from (select idMember, max(weight) as w from Measurements m
3      where m.date = (select min(date)  from Measurements n
4                      where m.idMember = n.idMember)
5      group by idMember) s0
6join (select idMember, min(weight) as w from Measurements m
7      where m.date = (select max(date)  from Measurements n
8                      where m.idMember = n.idMember)
9      group by idMember) s1
10on s0.idMember = s1.idMember
11