求个SQL 写错了,应该是不能这样写:select *from testwhere col2 = (select max(col2)from testwhere rownum=1) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 也不可以这样写:select *from(select *from testorder by col2 desc)where rownum = 1总之是不要出现两个SELECT select * from test where rownum=1 order by col2 desc; select * from (select * from test order by col2 desc)where rownum=1 select * from test where col2 = (select max(col2) from test) and rownum=1; to zhpsam109(昊子鳖鳖) : 你这种显然是错误的啊 select * from test where col2 = (select max(col2) from test) and rownum=1;加上 and rownum=1 是确保只返回一条。适用于最大值多个的情况 不好意思,我提问的时候写错了,不能这样写select *from testwhere col2 = (select min(col2)from test)and rownum=1我的意思是一个SQL语句中不要出现两个SELECT,且能达到要求 我的意思是一个SQL语句中不要出现两个SELECT,且能达到要求------------------------------------------------------楼主这个要求也太那个了,不过也有办法select distinct first_value(col1) over(order by col2 desc) col1, first_value(col2) over(order by col2 desc) col2, first_value(col1) over(order by col2 desc) col3from test; 写错了点:(select distinct first_value(col1) over(order by col2 desc) col1, first_value(col2) over(order by col2 desc) col2, first_value(col3) over(order by col2 desc) col3from test; 怎么根据外键删除主表和附表中的相关数据? cm_concat里的排序问题 oracle中sql问题 创建游标出问题(不好意思,我分数用完了,问题挻重要的,谢谢) 请问:我想赋予用户可以连接其他用户,并且可以在其他用户的数据库下创建表,但是不能删除表的权利,请问如何写命令 scott用户??? 怎样进行数据库的压力测试,有哪些工具,谢谢 表的关联 Oracle网站上的Oracle9i for Linux的版本得怎么下载啊? oracle数据库中可不可以设置一列的值自动增加??? oracle中数据的导出和导入的问题(急急!!!!!) 为什么表的最后一条记录显示不出来?
select *
from
(select *
from test
order by col2 desc)
where rownum = 1
总之是不要出现两个SELECT
(select * from test order by col2 desc)
where rownum=1
不能这样写
select *
from test
where col2 =
(select min(col2)
from test)
and rownum=1
我的意思是一个SQL语句中不要出现两个SELECT,且能达到要求
楼主这个要求也太那个了,不过也有办法select distinct first_value(col1) over(order by col2 desc) col1,
first_value(col2) over(order by col2 desc) col2,
first_value(col1) over(order by col2 desc) col3
from test;
first_value(col2) over(order by col2 desc) col2,
first_value(col3) over(order by col2 desc) col3
from test;