'Get the SUM of Two COUNTS in Sequelize
Is there a way to add/sum two attribute COUNT functions with sequelize? I want to get the sum of impMeta1Count and impMeta2Count.
imp.findAll({
attributes: {
include: [
[Sequelize.fn("COUNT", Sequelize.col('meta1.impId')), 'impMeta1Count'],
[Sequelize.fn("COUNT", Sequelize.col('meta3.impId')), 'impMeta2Count']
]
},
include: [
{ model: meta1, attributes: [], required: false },
{ model: meta2, attributes: [], required: false }
],
group: ['imp.id']
})
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
