日期:2014-05-18  浏览次数:20585 次

如何查询出价格为第三大
Create   table   Cost
(
        ID   int   primary   key,
        cost   int   not   null

)
insert   into   Cost   values(1,200)
insert   into   cost   values(2,300)
insert   into   cost   values(3,150)
insert   into   cost   values(4,160)

结果如下:
-----------------
ID               Cost
4                 160


------解决方案--------------------
select * from Cost as tmp
where (select count(*) from Cost where cost> =tmp.cost)=3

--result
ID cost
----------- -----------
4 160