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
Post a Comment