I have two tables - customer
and order
with one-to-many relationship. I want to retrieve in a single query all customer data and total value of his orders.
In raw SQL that would be something like this:
select customer.*, o.total from customer
inner join (select sum(value) as total, customer_id from
order group by customer_id) as o
on customer.id=i.customer_id
My question is - how to express this query in Sequelize without writing SQL? Is this even possible?