我有 UserStat 表,其属性和值定义为字符串...当我从 user_stats where property = 'BEST_SCORE'" 中选择 (CAST(value as integer) ) 时,一切都很好:
UserStat.find_by_sql(" select (CAST(value as integer) ) from user_stats where property = 'BEST_SCORE'") UserStat Load (8.6ms) select (CAST(value as integer) ) from user_stats where property = 'BEST_SCORE'
=> [#< UserStat id: nil, value: 869>]
但是当我这样做时:
UserStat.find_by_sql(" select AVG(CAST(value as integer) ) from user_stats where property = 'BEST_SCORE'")
UserStat Load (9.7ms) select AVG(CAST(value as integer) ) from user_stats where property = 'BEST_SCORE'
=> [#< UserStat id: nil>]
我的值字段在哪里???我想我必须得到 869 作为价值..