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

apache - Remove .php and add trailing slash in url using htaccess not loading css -

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