Rails 2で作業していますが、クエリを実行したい
PunchingInformation.all(
:select => "users.id, login, firstname, lastname,
sec_to_time(avg(time_to_sec(punching_informations.punch_in_time))) as 'avg_pit',
sec_to_time(avg(time_to_sec(punching_informations.punch_out_time))) as 'avg_pot'",
:joins => :user,
:group => "users.id",
:conditions => {
"punching_informations.date between '#{start_date}' and '#{end_date}'",
["punching_informations.user_id IN (?)", employees.map { |v| v.to_i } ]
}
)
しかし、それは常に次のようなエラーを返します
Mysql :: Error:不明な列'punching_informations.date between' 2012-09-01'and' 2012-09-25''in' whereclause':SELECT users.id、login、firstname、lastname、sec_to_time(avg(time_to_sec (punching_informations.punch_in_time)))as'avg_pit'、sec_to_time(avg(time_to_sec(punching_informations.punch_out_time)))as'avg_pot' FROM
punching_informations
INNER JOINusers
ONusers
.id =punching_informations
.user_id AND(users
。type
=' User'ORusers
。type
='AnonymousUser' )WHERE(.IN('punching_informations.user_id IN(?)'、'--- \ n- 28 \ n- 90 \ n'))GROUP BYpunching_informations
users.iddate between '2012-09-01' and '2012-09-25'
君の力が必要。