| 发表于:2007-02-07 09:20:39 楼主 |
在sql server中 select top 1 id from table1 order by price desc 会先将price排逆序 然后取第一个 这根下面这个是一样的 select id from table1 where price=(select max(price) from table1) 在oracle中好像只能用第二种方式来写 select id from table1 where rownum=1 order by price desc 好像是先随机取一条数据 然后把rownum=1 附加在该记录后面 明显不符合要求 如果先排序 select id from (select id from table1 order by price desc ) where rownum=1 我的目的就是先排序 然后再取第一条(这个是否应该也是从括号里面select的结果中随机取一条记录? 并不一定取price最大的那个) 如果出现上面这种情况,sql语句一般怎么处理? |
|
|
|
|