Rails SQL查询被转换为COUNT

时间:2017-09-17 20:33:20

标签: mysql sql ruby-on-rails

我有这段代码:

@people.count

生成以:

开头的查询
SELECT COUNT(*) FROM ( SELECT * .....

这个错误:

column "peoplerelationships.updated_at" must appear in the GROUP BY clause or be used in an aggregate function
LINE 5:    ORDER BY    peoplerelationships.updat...

如果我只查询@people,则没有错误。通过请求COUNT,它会向查询引入聚合函数,从而引入错误。您能否确保首先评估@people,然后计算?你怎么做得好?

0 个答案:

没有答案