Rails activerecord查询函数按功能排序?

时间:2013-11-19 22:22:31

标签: ruby-on-rails ruby activerecord

如果我这样做

self.order("extract(year, day), extract(month, day)")

我得到了

ActiveRecord::StatementInvalid: PG::Error: ERROR:  syntax error at or near "DESC"
LINE 19: ...>= '08-01-2012') GROUP BY 1 ORDER BY extract(year DESC, day)...

有没有办法用activerecord正确格式化这个查询?

1 个答案:

答案 0 :(得分:0)

你试过做错误建议你做的事情:

extract(year DESC, day)