-1
嗨,我正在尝试编写rails的postgres查询。怎么做。任何一个可以告诉如何在rails中编写postgres查询
这里是我的查询
SELECT
avg(company_ratings.satisfaction+
company_ratings.work_environment+
company_ratings.cd+
company_ratings.flexibility
)as averageall
FROM
public.company_ratings
WHERE
company_ratings.company_id = company_ratings.id;
你好根据你的建议,并按照指导我有查询作为
ratings.average('satisfaction+ work_environment+cd+flexibility')
语法
Client.average("orders_count")
但我我得到以下错误。
PG::UndefinedColumn: ERROR: column "satisfaction" does not exist
LINE 1: SELECT AVG(satisfaction+ work_environment+cd+flexi...
^
: SELECT AVG(satisfaction+ work_environment+cd+flexibility) AS avg_id FROM "ratings" WHERE "ratings"."company_id" = $1
所以我不明白我的error.As我正在学习轨道
转到谷歌,输入“rails guides query interface”并按回车。 –
查询错误?或者是什么? –
嗨根据你的建议,我尝试过,但我得到以下错误。 – user3144005