本帖最后由 iefus 于 2011-08-04 18:59:18 编辑

解决方案 »

  1.   

    select group,type,num,round(num/(count(1)over(partition by group))) from tableb t,tablea t1 where t.group=t1.group
      

  2.   

    select group,type,num,round(num/(count(1)over(partition by group))) from tableb t,tablea t1 where t.group=t1.group
      

  3.   


    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