我在pg生产模式下收到此错误,但它在sqlite3开发模式下工作正常.
ActiveRecord::StatementInvalid in ManagementController#index
PG::Error: ERROR: column "estates.id" must appear in the GROUP BY clause or be used in an aggregate function
LINE 1: SELECT "estates".* FROM "estates" WHERE "estates"."Mgmt" = ...
^
: SELECT "estates".* FROM "estates" WHERE "estates"."Mgmt" = 'Mazzey' GROUP BY user_id
@myestate = Estate.where(:Mgmt => current_user.Company).group(:user_id).all
Run Code Online (Sandbox Code Playgroud) 我有下表(高分),
id gameid userid name score date
1 38 2345 A 100 2009-07-23 16:45:01
2 39 2345 A 500 2009-07-20 16:45:01
3 31 2345 A 100 2009-07-20 16:45:01
4 38 2345 A 200 2009-10-20 16:45:01
5 38 2345 A 50 2009-07-20 16:45:01
6 32 2345 A 120 2009-07-20 16:45:01
7 32 2345 A 100 2009-07-20 16:45:01
Run Code Online (Sandbox Code Playgroud)
现在在上述结构中,用户可以多次玩游戏,但我想显示特定用户的"游戏玩法".所以在游戏部分我不能展示多个游戏.因此,概念应该是如果用户玩了3次游戏,则应该显示具有最高分数的游戏.
我想要结果数据,如:
id gameid userid name score date
2 39 2345 A 500 2009-07-20 16:45:01
3 31 2345 A 100 2009-07-20 16:45:01
4 38 …Run Code Online (Sandbox Code Playgroud)