现有一张数据表 编号 最小时间 最大时间
01 2007-01-01 2007-02-01
02 2007-02-01 2007-03-01
03 2007-03-01 2007-05-01
我想得到这样的结果集 ,时间取极值、编号数据不变编号 最小时间 最大时间
01 2007-01-01 2007-05-01
02 2007-01-01 2007-05-01
03 2007-01-01 2007-05-01请问如何实现?
01 2007-01-01 2007-02-01
02 2007-02-01 2007-03-01
03 2007-03-01 2007-05-01
我想得到这样的结果集 ,时间取极值、编号数据不变编号 最小时间 最大时间
01 2007-01-01 2007-05-01
02 2007-01-01 2007-05-01
03 2007-01-01 2007-05-01请问如何实现?
解决方案 »
- 数据库事务隔离级别Read Committed和Repeatable Read的区
- oracle 9i exp imp的数据转移问题
- 数据导入导出求助
- ORACLE 中查询某个表中某条记录的修改记录方法如下:
- oracle 热备份
- 老生常问的exp/imp问题,为什么不支持要求的字符集转换
- 向oracle 中插入纪录,日期格式由问题,见内
- Oracle里面有没有管理BLOB对象的工具?
- 求:Oracle事务处理比较完整的一个例子
- 老问题,新问!!oracle7.3 移植到oracle8i的方法??
- 如何解决启动OracleOraHome92ManagementServer服务就报1053的错误
- 启动不了SQLPLUS
select 编号,
(select min(最小时间) from tb) 最小时间,
(select max(最大时间) from tb) 最大时间
from tb t
insert into tb values('01' , '2007-01-01' , '2007-02-01')
insert into tb values('02' , '2007-02-01' , '2007-03-01')
insert into tb values('03' , '2007-03-01' , '2007-05-01')
goselect 编号,
(select min(最小时间) from tb) 最小时间,
(select max(最大时间) from tb) 最大时间
from tb tdrop table tb/*
编号 最小时间 最大时间
---- ---------- ----------
01 2007-01-01 2007-05-01
02 2007-01-01 2007-05-01
03 2007-01-01 2007-05-01(所影响的行数为 3 行)*/
from table_name,(select min(最小时间) mint,max(最小时间) maxt from table_name) t
over()在oracle 中有什麼作用,應該怎麼用? 謝謝!
from tabname a join
(
SELECT MAX(time1) as time1,max(time2) as time2 from tabname
) b on 1=1这个方法你测试下,是否满足要求
http://www.japee.com.cn/jew/pages/JPF2023_daoxian.aspx
insert into tb values('01' , '2007-01-01' , '2007-02-01') ;
insert into tb values('02' , '2007-02-01' , '2007-03-01');
insert into tb values('03' , '2007-03-01' , '2007-05-01');
select tb.编号 ,t2.mintime,t2.maxtime
from tb ,(select min(最小时间) mintime ,max(最大时间) maxtime from tb) t2;编号 mintime maxtime
---- ---------- ----------
01 2007-01-01 2007-05-01
02 2007-01-01 2007-05-01
03 2007-01-01 2007-05-01