sum统计某字段满足某种条件的记录数

(1)count来查询:

SELECT count(*) from lw_devices_type_relation where is_standard = 1

查询 lw_devices_type_relation 表中满足is_standard为1的数量。

(2)sum来查询:

select sum(is_standard = 1) from lw_devices_type_relation

查询 lw_devices_type_relation 表中满足is_standard为1的数量。

原文地址:https://www.cnblogs.com/chenmz1995/p/10247115.html