oracle

with T as  (select GId, gname, gcolour, gwithin, gsize, sum(gnumber) gnumber     from t_goods    group by GId, gname, gcolour, gwithin, gsize   union all   select gid, gname, null, null, '小计', sum(gnumber)     from t_goods    group by gid, gname) select rownum seq,        decode(rn, 1, gid) gid,        decode(rn, 1, gname) gname,        gcolour,        gwithin,        gsize,        gnumber   from (select t.*, row_number() over(partition by gid order by gnumber) rn           from t);

 

posted @ 2013-09-27 15:04  smail2013  阅读(136)  评论(0编辑  收藏  举报