从前3000个记录中取前10条,前10条/3000条
select (select sum(field) from ( select top 10 * from table ) a)/(select sum(field) from (select top 3000 * from table) b)

解决方案 »

  1.   

    select top 10 * from table1 compute 10*/count(*)
      

  2.   

    如果是所有记录:
    select ((select sum(field) from (select top 10 * from table) a)/(select sum(field) from table))*100 (百分比)
      

  3.   

    上面笔误,因为 10/ ,未测试
    最好把你的字段,SUM分组的要求,写出来..
      

  4.   


    select top 10 qty from stock order by qty;
    还是
    select qty from stock order by qty top 10;
      

  5.   

    就拿select top 10 qty from stock order by qty;
    举例好吗
      

  6.   

    select ((select sum(qty) from (select top 10 qty from stock order by qty) a)/(select sum(qty) from stock order by qty))*100
      

  7.   

    top 10取前10条记录
    select top 10 qty from stock order by qty compute sum(field1)
      

  8.   

    还有一个办法就是生成带ID的临时表
    最后百分比放在那个字段位置,你自己决定,然后两结果做UNION ALL
      

  9.   

    有一点没有说清楚,
    我用的是ORCALE里面的SQL * PLUSTOP N 的语法好象用不起来