有两张表
A data_index_err
B data_index_his
求两张表占A、B数据总数的比例
with table_sum as
(select count(1) as total from data_index_his
union all
select count(1) as total from data_index_err)
select sum(total) as total from table_sum
union all
select total/sum(total)*1.0 as "percent"
from table_sum group by total;
结果:
为什么结果和期望的不一致啊?~~~~