sequelize subquery as field

Your best option is: return Customer.findAll({ attributes: Object.keys(Customer.attributes).concat([ [sequelize.literal(‘(SELECT SUM(“Orders”.”amount”) FROM “Orders” WHERE “Orders”.”CustomerId” = “Customer”.”id”)’), ‘totalAmount’] ]) }); This looks like an extension to issue #1869: Querying on the through model/join table is not possible currently unfortuneatly. Your question is also tangentially related to this one, where the question there was sort of a … Read more