我有以下查询..
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;
我想得到"总和(sl.qty * sl.factor)为数量"字段舍入到小数点后两位。 例如。如果结果得到了13.170000484884',我想进入' 13.17'结果。
答案 0 :(得分:0)
使用ROUND()
功能:
ROUND(sum(sl.qty*sl.factor),2) as qty
查询:
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;