php - Return positive value always even if it is negative -


select c.firstname,c.lastname,s.salesprice,p.recommendedprice,s.salesprice - p.recommendedprice  customers c inner join sales s on c.customerid=s.customerid inner join products p on s.productid=p.productid 

i know maths has function don't know specific function use in mysql.

i have difference table needs returned positive.

for example: difference -50 , want +50 in column.

according query s.salesprice - p.recommendedprice calculating price has refunded. put abs before calculation. below query

select c.firstname,c.lastname,s.salesprice,p.recommendedprice,abs(s.salesprice - p.recommendedprice)  customers c inner join sales s on c.customerid=s.customerid inner join products p on s.productid=p.productid 

for more information


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -