<SQL>求A、B两张表占两表数据量总和的比例

有两张表

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;

结果:
微信截图_20191129102554.png
为什么结果和期望的不一致啊?~~~~

阅读 2k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进