用于选择多个计数列的MySQL查询

用于选择多个计数列的MySQL查询,mysql,sql,Mysql,Sql,我有一张这样的桌子- 我想运行一个查询,这样我就可以有这样的输出- 我不知道怎么做。 所以,我所做的是- SELECT Count(* where status="Active") as count_active Count(* where status="Inctive") as count_inactive Count(* where status="Biase") as count_biase FROM `subscribers`

我有一张这样的桌子-

我想运行一个查询,这样我就可以有这样的输出-

我不知道怎么做。 所以,我所做的是-

SELECT
        Count(* where status="Active") as count_active
        Count(* where status="Inctive") as count_inactive
        Count(* where status="Biase") as count_biase
    FROM `subscribers`

如果出现错误,有人能帮忙吗?

可以通过一个
案例
表达式来实现这一点

查询

select 
count(case when status = 'Active' then 1 else null end) as Active_Count,
count(case when status = 'Inactive' then 1 else null end) as Inctive_Count,
count(case when status = 'Biase' then 1 else null end) as Biase_Count
from tbl_name;

这是将其放入单个寄存器的方法:

SELECT 
(SELECT count(id) FROM new_table where status = 'Active') as Active_Count,
(SELECT count(id) FROM new_table where status = 'Inactive') as Inctive_Count,
(SELECT count(id) FROM new_table where status = 'Biase') as Biase_Count;