New Discussion

Notifications

You’re not receiving notifications from this thread.

How to write this raw SQL query in Active Record Query Interface

0
Rails

Here's the SQL:

select s.name, p.name, count(i.id) as count from items i
left join products p
on p.id = i.product_id
left join stores s
on s.id = i.store_id
group by p.id, s.id

Thank you.

Join the discussion
Create an account Log in

Learning Ruby on Rails? Join our newsletter.

We won't send you spam. Unsubscribe at any time.