问题1
SELECT
f.MANHOUR_TOTAL,
f.MATERIAL_TOTAL,
e.NILAI_RATE * f.MANHOUR_TOTAL AS LABOUR_TOTAL
现有数据是e.NILAI_RATE = 4.00
和MANHOUR_TOTAL = 11.00
。结果是44.0000。
如何在LABOUR_TOTAL上将逗号后面的两位数保留为44.00
问题2,我想将这些LABOUR_TOTAL用于下一步操作:
SELECT
f.MANHOUR_TOTAL,
f.MATERIAL_TOTAL,
e.NILAI_RATE * f.MANHOUR_TOTAL AS LABOUR_TOTAL
LABOUR_TOTAL + f.MATERIAL_TOTAL AS FINISHING_TOTAL
但是它给了我FINISHING_TOTAL的空值。有可能这样做吗?任何帮助和建议都非常感激。
答案 0 :(得分:1)
问题1你想要ROUND:
SELECT ROUND(e.NILAI_RATE * f.MANHOUR_TOTAL, 2) AS LABOUR_TOTAL
应该这样做!
对于问题2,请考虑以下事项:
SELECT
f.MANHOUR_TOTAL,
f.MATERIAL_TOTAL,
ROUND(e.NILAI_RATE * f.MANHOUR_TOTAL, 2) AS LABOUR_TOTAL,
ROUND((e.NILAI_RATE * f.MANHOUR_TOTAL) + f.MATERIAL_TOTAL, 2) AS FINISHING_TOTAL