【问题标题】:I want to use GROUP BY in Sequelize Nodejs how to use it我想在 Sequelize Nodejs 中使用 GROUP BY 如何使用它
【发布时间】:2022-11-11 03:06:57
【问题描述】:
SELECT COUNT(volunteer_id) as countVolunteer, volunteer_type_id 
FROM `red_cross_vvts`
GROUP BY volunteer_type_id;

【问题讨论】:

  • 你试过什么?

标签: sequelize.js


【解决方案1】:
red_cross_vvts.findAll({
  attributes: ['volunteer_type_id', [sequelize.fn('COUNT', 'volunteer_id'), 'countVolunteer']],
  group: ['volunteer_type_id'],
});

【讨论】:

    猜你喜欢
    • 2023-02-26
    • 2015-03-28
    • 1970-01-01
    • 1970-01-01
    • 2014-12-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多