Ruby on Rails
Tuesday, February 23, 2016
For some reason the following two queries return different results
-- Where there is only one activity record and price is 3.63 and quantity is 16.19, the following codes return results of different rounding.
sum("CEIL(`activities`.quantity/60) * 60 / 3600 * `activities`.price").to_s
"58.81"
sum("CEIL(`activities`.quantity/60) * 60 / 3600 * `activities`.price * 1").to_s
"58.806" # this is the correct one
I have checked the raw sql and both return 58.806.
I believe this is a bug for the sum method.
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/66038b1a-1306-4ef7-9e37-5ca6c89565cd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment