Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to get the sum of a column in sequelize

const totalAmount = await DONATIONS.findAll({
  attributes: [
    'member_id',
    [sequelize.fn('sum', sequelize.col('amount')), 'total_amount'],
  ],
  group: ['member_id'],
  raw: true
});
 Run code snippet
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #sum #column #sequelize
ADD COMMENT
Topic
Name
3+3 =