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

关于sql的一条查询语句?不知怎么写

2012-01-12 
关于sql的一条查询语句?不知如何写?表A有一个价格字段(price),我要用一条sql语句把价格最低,而且不重复的

关于sql的一条查询语句?不知如何写?
表A有一个价格字段(price),我要用一条sql语句把价格最低,而且不重复的那条记录取出来,比如
3.2
3.4
3.8
3.2
由于3.2有重复,所以应该取出3.4,如果3.2不重复,就取3.2,总之价格最低的那个不能重复,如果重复则去比他高一点的那条最低而且不重复的记录!


[解决办法]
select min(price) from 表A group by price having count(price)=1
[解决办法]
select top 1 price from ta group by price having count(price)=1 order by price
[解决办法]
select top 1 price from 表
group by price
having count(*)=1
order by price asc

热点排行