【发布时间】:2020-02-16 14:30:26
【问题描述】:
这是桌子
- 标题
- post_count
- comment_count
我想得到 post_count 和 comment_count 的总和。 我做的就是这样,但是不行。
.select("count(tables.post_count + tables.comment_count) AS field_name").where("field_name >= ?", 3)
【问题讨论】:
-
你能提供一个简单的例子来说明你的表格是什么样的,以及你的预期结果吗?
-
例如摘要表有这些列。 “post_count”,是整数,它有总帖子数 “comment_count”,它是整数,它有总评论数我想要post_count + comment_count的总和
-
我根据我的理解添加了一个答案,我会让你检查这是否是你要找的。span>
标签: ruby-on-rails postgresql activerecord