Ask A Question
Notifications
You’re not receiving notifications from this thread.
How to write this raw SQL query in Active Record Query Interface
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.