How to convert SQL query to Ruby on Rails -


how convert following sql query ruby on rails?

select health_workers.name,health_workers.surname,clinics.name clinic,count(observations.id) count,observations.observation_date  health_workers  left join observations on health_workers.id = observations.health_worker_id, clinics  health_workers.clinic_id = clinics.id  group  health_workers.name,health_workers.surname,clinics.name,observations.observation_date. 

you can way

query = "select health_workers.name,health_workers.surname,clinics.name clinic,count(observations.id) count,observations.observation_date  health_workers  left join observations on health_workers.id = observations.health_worker_id, clinics  health_workers.clinic_id = clinics.id  group  health_workers.name,health_workers.surname,clinics.name,observations.observation_date."   results = activerecord::base.connection.execute(query) 

and gives result


Comments

Popular posts from this blog

Why can rails not find a route created by a helper? -

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -