-3

I have the following query..

SELECT p.product_id,p.description,sum(sl.qty*sl.factor) as qty
FROM sale_line as sl
LEFT JOIN sale as s ON(sl.sale_id=s.sale_id)
LEFT JOIN product as p ON(p.product_id=sl.product_id)
ORDER BY sl.product_id DESC;

I want to get "sum(sl.qty*sl.factor) as qty" field to round into two decimal places. Eg. if the result get '13.170000484884', I want to round into '13.17' to the result.

Nyein Aung
  • 63
  • 1
  • 6
  • copy query here.don't make image for it. you can use `ROUND()` function of mysql. here it is link: http://www.w3resource.com/mysql/mathematical-functions/mysql-round-function.php – Pathik Vejani Jan 25 '16 at 05:07

1 Answers1

0

Use ROUND() funtion:

ROUND(sum(sl.qty*sl.factor),2) as qty

Query:

SELECT p.product_id,p.description,ROUND(sum(sl.qty*sl.factor),2) as qty
FROM sale_line as sl
LEFT JOIN sale as s ON(sl.sale_id=s.sale_id)
LEFT JOIN product as p ON(p.product_id=sl.product_id)
ORDER BY sl.product_id DESC;
Pathik Vejani
  • 4,263
  • 8
  • 57
  • 98