例如:已执行(默认):
SELECT if(`evaluates`.`all`, 'good','notgood') AS `sign`, count(*) AS `count` FROM `evaluates` AS `evaluates` WHERE `evaluates`.`deleted_at` IS NULL GROUP BY `sign`;
await DBC.evaluates.count({
attributes: [[DBC.sequelize.fn(['if'],
DBC.sequelize.col("`evaluates`.`all`"), ["good", "notgood"]), 'sign']],
group: ["sign"]
});
但执行(默认):
SELECT if(`evaluates`.`all` > 3, 'good','notgood') AS `sign`, count(*) AS `count` FROM `evaluates` AS `evaluates` WHERE `evaluates`.`deleted_at` IS NULL GROUP BY `sign`;
如何?
await DBC.evaluates.count({
attributes: [[DBC.sequelize.fn(['if'], DBC.sequelize.col("`evaluates`.`all` > 3"), ["good", "notgood"]), 'sign']],
group: ["sign"]
});?
这是假的。
答案 0 :(得分:1)
literal(“evaluates
。all
> 3”)