![](/img/trans.png)
[英]Providing a join count and total count in the same query with Active Record
[英]Total value of warehouse active record
我有对象工具,我需要计算仓库中所有工具的成本。 我可以总结列价格Tool.sum(:price)
但我需要总结所有表工具的(数量 * 价格)。 提前致谢。
create_table "tools", force: :cascade do |t|
t.integer "quantity"
t.string "name"
t.integer "price"
t.boolean "avilable"
t.string "store"
t.string "comments"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.