Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
次のようなクエリを実行する場合:
select sum(items) from my_table where ...
私が返している結果(ルビー)はタイプBigDecimalです。を取り戻すために適用できる SQL マジックはありますintか?
BigDecimal
int
列に対してこのような操作を実行すると、BigDecimalの結果が得られNUMERICます。おそらく必要なのは、collect操作を使用してRubyで変換するか、MySQLレベルで整数にキャストしてから返すことです。
NUMERIC
collect
SELECT FLOOR(SUM(items)) FROM my_table WHERE ...
select cast(sum(items) as binary) ...
私にとってはうまくいきました