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

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

javascript - jquery or ashx not working -

inno setup - TLabel or TNewStaticText - change .Font.Style on Focus like Cursor changes with .Cursor -