当前位置: 代码迷 >> Sql Server >> 关于平均值的SQL话语,求帮助
  详细解决方案

关于平均值的SQL话语,求帮助

热度:23   发布时间:2016-04-24 23:25:23.0
关于平均值的SQL语句,求帮助
假设有下面的表 
id 列A
1   1
2   1
3   3
4   6
5   6
6   9
7   11
8   11
9   11
求列A去掉最大值最小值(即去掉1跟11)的平均值的SQL语句

------解决方案--------------------
select avg(A) from 表 
where a!=(select max(a) from 表) and a!=(select min(a) from 表)
------解决方案--------------------
select avg(列A)
from tab 
where id not in (select top 1 id from tab order by 列A ,id)
and id not in (select top 1 id from tab order by 列A desc,id desc)

  相关解决方案