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)
按照其中的某个字段从大到小都排好了,取前9个SELECT TOP 9 * FROM TB ORDER BY COL DESC
前九个 这样取select top 9 字段 from 表 order by 字段九个后面的累计select sum(字段) from 表 where 主键 not in(select top 9 主键 from 表 order by 字段)
9个以后的值相加select sum(col) as col from tb where not exists(SELECT TOP 9 * FROM TB ORDER BY COL DESC) ORDER BY COL DESC
前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
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
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)
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' 附近有语法错误。”
union
select sum(col) as col rom table where col not in(select top 9 col from table order by col)
exists(SELECT TOP 9 * FROM TB ORDER BY COL DESC) ORDER BY COL DESC
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
select sum(colName)-(select sum(colName) from (select top 9 * from tableName
order by colName desc) b) from tableName
select sum(colname) as colname from table where colname not in(select top 9 colname from table order by colname desc)
union
select sum(col) as col rom table where col not in(select top 9 col from table order by col)
这样写出现“在关键字 'union' 附近有语法错误。”