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.
请帮我在rails上构建查询。我有 2 个模型 - 订单(名称、评论)和任务(订单 ID、表格编号)(例如),订单有很多任务。我如何选择订单,他们的任务 sheet_num 的总和大于零?
导轨 2.3.4 =>
Order.joins(:tasks).group(:order_id).having("sum(sheets_num) > 0").all