现有表monitor_indexforecast,
各字段分别是: TYPE ITIME FCDATE FCHH VTI CITYNUMBER DATASOURCE INDEXFILENAME ERRSTATION
原来做法是先:select dinstinct(type||vti) from monitor_indexforecast,这样将得到84条记录
将获取到的type||vti分别保存在两个数组中,然后再执行:select * from monitor_indexforecast where itime=(select max(itime) from monitor_indexforecast where type like '%type_array[i]%' and vti like '%vti_array[i]%')这样相当于要先执行一次查询,再执行84条查询来获取想要的记录,有没有一条语句获取到想要的记录集达到这85条SQL的效果?
各字段分别是: TYPE ITIME FCDATE FCHH VTI CITYNUMBER DATASOURCE INDEXFILENAME ERRSTATION
原来做法是先:select dinstinct(type||vti) from monitor_indexforecast,这样将得到84条记录
将获取到的type||vti分别保存在两个数组中,然后再执行:select * from monitor_indexforecast where itime=(select max(itime) from monitor_indexforecast where type like '%type_array[i]%' and vti like '%vti_array[i]%')这样相当于要先执行一次查询,再执行84条查询来获取想要的记录,有没有一条语句获取到想要的记录集达到这85条SQL的效果?
解决方案 »
- oracle中两个游标同时打开运行,两个游标值是一一对应?请问咋写?
- 紧急求助 oracle建索引失败后 RAC宕机!
- 表优化
- 通过IMP/EXP将从低版本ORACLE导出的数据导入高版本ORACLE数据库的问题
- CASE语句用在Procedure中报错
- 我的pl/sql访问不了远程数据库了
- ORACLE存储过程中的ELSE IF语句怎么写,我这样写为何报错?应该怎么写?
- 请教sql语句?谢谢
- UPDATE利用另外一张表内容更新表内容,在ORACLE中出错
- oracle中修改列名
- 有关C# 中连接ORACLE数据库的问题?? 技术达人请进!
- 【新年快乐】求一个简单的oracle触发器,可是我不会写
(select type||vti tv, max(itime) mt from monitor_indexforecast group by type||vti) t1
where t.type||t.vti=t1.tv and t.itime=t1.mt
(select type||vti tv, max(itime) mt from monitor_indexforecast group by type||vti) t1
where t.type||t.vti=t1.tv and t.itime=t1.mt
--不用数组,试一下:select dinstinct(type || vti)
from monitor_indexforecast
union
select a.type || a.vti max_t_v
from monitor_indexforecast a,
(select max(itime) mi from monitor_indexforecast) b
where a.itime = b.mi;
select t.* from monitor_indexforecast t
(select type||vti tv,itime mt,row_number() over(order by itime desc) rn from monitor_indexforecast) t1
where t.type||t.vti=t1.tv and t.itime=t1.mt and t1.rn=1
将上面的再改一下
select t.* from monitor_indexforecast t
(select type||vti tv,itime mt,row_number() over(partion by type||vti order by itime desc) rn from monitor_indexforecast) t1
where t.type||t.vti=t1.tv and t.itime=t1.mt and t1.rn=1