用 union all
select 前九个
union all
select 九个后面的累计

解决方案 »

  1.   

    通过系统表找出所有字段名.然后组合成SQL语句字符串,然后执行
      

  2.   

    select top 9 col from table order by col
    union 
    select sum(col) as col rom table where col not in(select top 9 col from table order by col)
      

  3.   

    按照其中的某个字段从大到小都排好了,取前9个SELECT TOP 9 * FROM TB ORDER BY COL DESC
      

  4.   

    前九个 这样取select top 9 字段  from 表  order by 字段九个后面的累计select sum(字段) from 表 where 主键 not in(select top 9 主键 from 表 order by 字段)
      

  5.   

    9个以后的值相加select sum(col) as col from tb where not 
    exists(SELECT TOP 9 * FROM TB ORDER BY COL DESC) ORDER BY COL DESC
      

  6.   

    前9个合计:select sum(字段) from (
    select top 9 * from tablename order by ...
    ) as t后面的合计=全部的合计-前9个合计:select sum(字段)-(
    select sum(字段) from (
    select top 9 * from tablename order by ...
    ) as t
    ) as 后面的合计
    from tablename
      

  7.   

    select sum(colName) from (select top 9 * from tableName order by colName desc) a union
    select sum(colName)-(select sum(colName) from (select top 9 * from tableName
    order by colName desc) b) from tableName
      

  8.   

    select top 9 colname from table order by colname desc union 
    select sum(colname) as colname from table where colname not in(select top 9 colname from table order by colname desc)
      

  9.   

    select top 9 col from table order by col
    union 
    select sum(col) as col rom table where col not in(select top 9 col from table order by col)
    这样写出现“在关键字 'union' 附近有语法错误。”
      

  10.   

    uion两个表时,select出的数据类型,数量要一致才行