怎么用sql算出两个表中数量的百分比
发布网友
发布时间:2022-04-08 05:49
我来回答
共3个回答
热心网友
时间:2022-04-08 07:18
with t1 as (select count(*) f from a), t2 as (select count(*) f from b)
select (select f*1. from a)/((select f from a)+(select f from b))
热心网友
时间:2022-04-08 08:36
select
f1/(f1+f2)*100.00,
f2/(f1+f2)*100.00
from
(select (select count(*) from t1) as f1,(select count(*) from t2) as f2 ) as t_t
热心网友
时间:2022-04-08 10:11
;with t
as
(
select count(聚集索引所在字段) as total from a
union all
select count(聚集索引所在字段) from b
)
select sum(total ) as total from t
union all
select total /sum(total )*1.0 as 百分比 from t group by total