首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

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

2013-03-13 
关于平均值的SQL语句,求帮助假设有下面的表 id 列A112133465669711811911求列A去掉最大值最小值(即去掉1跟

关于平均值的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)

热点排行