我一直在使用它来获取一天的每小时数据,所以我尝试过这样
@getting_each_day = Order.group_by_hour_of_day("2014-08-22 00:00:00").count
但它显示 postgresql 错误.....
PG::Error: ERROR: syntax error at or near "00"
LINE 1: ...UNT() AS count_all, EXTRACT(HOUR from 2014-08-22 00:00:00::...
^
: SELECT COUNT() AS count_all, EXTRACT(HOUR from 2014-08-22 00:00:00::timestamptz AT TIM
ZONE 'Asia/Muscat' - INTERVAL '0 hour')::integer AS hour_of_day FROM "orders" WHERE (2014-
08-22 00:00:00 IS NOT NULL) GROUP BY EXTRACT(HOUR from 2014-08-22 00:00:00::timestamptz AT
TIME ZONE 'Asia/Muscat' - INTERVAL '0 hour')::integer
但它正在使用Order.group_by_hour_of_day(:created_at).count
我的查询有什么问题吗?另外,我尝试过使用时区,但得到了同样的错误。