[Chartjs]-I dont know how to sum expenses based on category in sequelize

1👍

You can use this –

Expense.findAll({
    attributes : ['categoryId', [db.sequelize.fn('SUM', db.sequelize.col('amount')), 'total']],
    group : ['categoryId']
});

This will result in list of categories with their sum. You can apply other aggregate function too.

Leave a comment