日期:2014-05-16 浏览次数:20719 次
一: 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
------解决方案--------------------
你就直接UNION吧。
------解决方案--------------------
直接union all性能会好一些的。
------解决方案--------------------
union all就可以的。