嗨,我的一个查询陷入了奇怪的问题。
公式:(28800/3600-(28382.6/3600-(1920/3600+1860/3600))) =
所以,输入方程:
= (28800/3600-(28382.6/3600-(1920/3600+1860/3600)))
= (28800/3600-(28382.6/3600-(0.53333333333333+1860/3600)))
= (28800/3600-(28382.6/3600-(0.53333333333333+0.51666666666667)))
= (28800/3600-(28382.6/3600-(1.05)))
= (28800/3600-(28382.6/3600-1.05))
= (28800/3600-(7.8840555555556-1.05))
= (28800/3600-(6.8340555555556))
= (28800/3600-6.8340555555556)
= (8-6.8340555555556)
= (1.1659444444444)
= 1.1659444444444
但是我从查询中得到 0 作为输出,它应该打印 1
select (to_char (NULLIF(GREATEST(coalesce(28800/3600,0) - (coalesce(28382.6/3600,0) -
(coalesce(1920/3600,0) + (coalesce(1860/3600,0)))),0),0),'FM99,999,999,999'))::character varying as mydatas
现在,相同的公式和具有不同值的相同查询可以正常工作。请检查以下。
(28800/3600-(13552.24/3600-(900/3600+0/3600)))
输入方程:
= (28800/3600-(13552.24/3600-(900/3600+0/3600)))
= (28800/3600-(13552.24/3600-(0.25+0/3600)))
= (28800/3600-(13552.24/3600-(0.25+0)))
= (28800/3600-(13552.24/3600-(0.25)))
= (28800/3600-(13552.24/3600-0.25))
= (28800/3600-(3.7645111111111-0.25))
= (28800/3600-(3.5145111111111))
= (28800/3600-3.5145111111111)
= (8-3.5145111111111)
= (4.4854888888889)
= 4.4854888888889
所以我的查询也给出了 4 作为输出
select (to_char (NULLIF(GREATEST(coalesce(28800/3600,0) - (coalesce(13552.24/3600,0) -
(coalesce(900/3600,0) + (coalesce(0/3600,0)))),0),0),'FM99,999,999'))::character varying as mydatas