多个表 t1,t2,t3..... 其中都有两个字段id,rq我想取每个表的第一条数据 ,按日期排序id
t1id
t2id
t3id
.....不想用下列办法,还有其他办法吗?》
select id from t1 where rownum=1 order by rq union
select id from t2 where rownum=1 order by rq union
select id from t3 where rownum=1 order by rq
t1id
t2id
t3id
.....不想用下列办法,还有其他办法吗?》
select id from t1 where rownum=1 order by rq union
select id from t2 where rownum=1 order by rq union
select id from t3 where rownum=1 order by rq
解决方案 »
- 为啥这样sql(oracle)语句执行速度比较快,原因
- Oracle 11g中的SQL developer 连接中的connection name填什么?
- 请教各位老大,oracle+excel问题
- 这道题帮我写下怎么做,我想了很久
- 求SQL
- ora-06550 PLS-00103
- 请高手帮忙写下sql语句
- 用myclipse怎么连接orcale
- 如何把SQLSERVER中的视图导入到ORACLE中
- SqlServer中的ISNULL函数在Oracle中用哪个来代替,
- 这样在包头中定义关联数组,为什么出现警告信息?
- 我直接rm -rf * ORACLE安装目录下的所有文件后LINUX反应变得很慢,有没有解决办法呢?
--没想到其他方法,不过,最好用union all
SQL> create table t1 as
2 select * from scott.emp
3 order by hiredate desc;Table createdSQL> create table t2 as
2 select * from scott.emp
3 order by hiredate;Table createdSQL> select hiredate,job,ename from t1 where rownum=1
2 union all
3 select hiredate,job,ename from t2 where rownum=1
4 /HIREDATE JOB ENAME
----------- --------- ----------
1987-5-23 CLERK ADAMS
1980-12-17 CLERK SMITH