作者:-林之涵_396 | 来源:互联网 | 2023-10-15 19:40
Iwanttogettheaverageofthedifferencebetweenthecurrenttimeandadatetimevalueinthedat
I want to get the average of the difference between the current time and a datetime value in the database with Squeel:
我想用Squeel获取数据库中当前时间和日期时间值之间的差异的平均值:
Car.select{average(NOW() - created_at)}
Which tries to take "NOW" as a column in the database:
哪个尝试将“NOW”作为数据库中的列:
ActiveRecord::StatementInvalid: PGError: ERROR: column cars.NOW does not exist
LINE 1: SELECT avg("cars"."NOW" - "cars"."created_at") FROM "cars" ...
Any way to do this in Squeel?
在Squeel有什么办法吗?
1 个解决方案