关于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