select group,type,num,round(num/(count(1)over(partition by group))) from tableb t,tablea t1 where t.group=t1.group
select group,type,num,round(num/(count(1)over(partition by group))) from tableb t,tablea t1 where t.group=t1.group
with a as ( select 2 "group",100 num from dual union all select 3,80 from dual union all select 4,41 from dual ),b as ( select 2 "group",'banana' type from dual union all select 2,'apple' from dual union all select 3,'box' from dual union all select 3,'apple' from dual union all select 3,'dog' from dual union all select 4,'cat' from dual ) select a."group", b.type, round(num / count(num) over(partition by a."group")) "Num(四舍五入)" from a, b where a."group" = b."group"2 banana 50 2 apple 50 3 box 27 3 apple 27 3 dog 27 4 cat 41
with a as
(
select 2 "group",100 num from dual
union all
select 3,80 from dual
union all
select 4,41 from dual
),b as
(
select 2 "group",'banana' type from dual
union all
select 2,'apple' from dual
union all
select 3,'box' from dual
union all
select 3,'apple' from dual
union all
select 3,'dog' from dual
union all
select 4,'cat' from dual
)
select a."group",
b.type,
round(num / count(num) over(partition by a."group")) "Num(四舍五入)"
from a, b
where a."group" = b."group"2 banana 50
2 apple 50
3 box 27
3 apple 27
3 dog 27
4 cat 41