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

hibernate - How to load global settings frequently used in application in Java -

python 3.x - Mapping specific letters onto a list of words -

objective c - Ownership modifiers with manual reference counting -