日期:2014-05-17 浏览次数:21057 次
select * from T_Goods1;
with t as
(select GId, gname, gcolour, gwithin, gsize, sum(gnumber) gnumber
from T_Goods1
group by GId, gname, gcolour, gwithin, gsize
union all
select gid, gname,gcolour, null, 'gcolour小计', sum(gnumber)
from T_Goods1
group by gid, gname,gcolour
union all
select gid, gname, null, null, 'gname小计', sum(gnumber)
from T_Goods1
group by gid, gname
union all
select null, null, null, null, '总计', sum(gnumber)
from T_Goods1
)
select rownum seq,
decode(rn, 1, gid) gid,
decode(rn2, 1, gname) gname,
gcolour,
gwithin,
gsize,
gnumber
from (
select t.*, row_number() over(partition by gid order by gid,gname,gnumber) rn,
row_number() over(partition by gid,gname order by gid,gname,gnumber) rn2 from t);