56,687
社区成员
发帖
与我相关
我的任务
分享
一:
select count(*) as 总数 from A .....
union all
select count(*) as 有效数 from A where 条件='有效'
union all
select count(*) as 总数 from B .....
union all
select count(*) as 有效数 from B where 条件='有效'
union all
select count(*) as 总数 from C .....
union all
select count(*) as 有效数 from C where 条件='有效'
union all
select count(*) as 总数 from D .....
union all
select count(*) as 有效数 from D where 条件='有效'
union all
select count(*) as 总数 from E .....
union all
select count(*) as 有效数 from E where 条件='有效'
二:
select "A", count(*) as 总数, sum(if(条件='有效', 1, 0) as 有效数 from A
union
select "B", count(*) as 总数, sum(if(条件='有效', 1, 0) as 有效数 from B
union
select "C", count(*) as 总数, sum(if(条件='有效', 1, 0) as 有效数 from C
union
select "D", count(*) as 总数, sum(if(条件='有效', 1, 0) as 有效数 from D
union
select "E", count(*) as 总数, sum(if(条件='有效', 1, 0) as 有效数 from E