TP中統計指定字段的總數

如統計已激活設備數量和未激活設備數量this

$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();
            
相關文章
相關標籤/搜索