如统计已激活设备数量和未激活设备数量
$condition = [ ['member_id', '=', $member_id] ]; $field = [ 'COUNT(IF(active_member_id > 0, 1, null)) as actived_num', 'COUNT(IF(active_member_id = 0, 1, null)) as unactived_num', ]; $list = $this->where($where)->field($field)->order($order)->select();