http://expert.csdn.net/Expert/topic/1842/1842840.xml?temp=.9666254

解决方案 »

  1.   

    如果是在sqlplus命令行方式下得到上述的结果,需要用到column设置(查看sqlplus参考)。在select语句前使用column设置列格式,然后再查询。如果用报表工具就简单了。
      

  2.   

    select * from 
    (select 大组,小组,商品名称,rank() over(partition 大组,小组 order by sal desc) rk from table_name)
    where rk<=10 
    order by 大组,小组,sql desc
      

  3.   

    select * from 
    (select 大组,小组,sum(商品名称),rank() over(partition 大组,小组 order by sal desc) rk from table_name)
    where rk<=10 
    order by 大组,小组,sql desc
      

  4.   


    谢谢大家 
    hutulaodao(糊涂老道), beckhambobo(beckham) 按你们的说法做报错了我重新说明一下报表的格式
    大组号  商品编号  销售金额
    10      1000      1000.00
            3000      999.00
            2102      899.00
            ……………………
            (取金额前10)   
    20      34343      1000.00
            33433      339.00
            213223      299.00
            ……………………
            (取金额前10)   
    30     000      5200.00
            3000     2349.00
            2102      899.00
            ……………………
            (取金额前10)   
    每个大组里都有很多商品