两张表A,B结构分别如下:
A: id A1 A2 B1
B: id B1 B2
要求查出A中所有的记录并按照 B2的升序排列!
A: id A1 A2 B1
B: id B1 B2
要求查出A中所有的记录并按照 B2的升序排列!
解决方案 »
- 如何查找字段长度在某个范围内的所有记录?求高手!
- 求助:load()clob字段的读取不出来
- OEM中为什么找不到“Net 服务管理”
- 在线急求:oracle8.0解锁用户
- 请教一下这段sql server 语句 装换成oracle 该怎么写
- 请高手指点一下我这个java的初哥,关于java调用oracle储存过程的问题?
- oracle中sysdba用户通过odbc数据源连接,怎样配置?
- 在客户端登陆远程服务器(通过代理中转),如何配置
- 为什么呢我的存储过程老提示large pool 太小??
- oracle 中提取时间的问题
- 这个SQL怎么写
- 急!怎么将Oracel中全角的数字(nvarchar2)转为int类型的数字。
select a.*
from a,b
where a.id=b.id
order by b.b2 asc;
SQL> with b as(
2 select 4 id,to_date('2011-04-01','yyyy-mm-dd') dt from dual union all
3 select 3,to_date('2005-12-25','yyyy-mm-dd') from dual union all
4 select 5,to_date('2010-05-21','yyyy-mm-dd') from dual union all
5 select 1,to_date('2014-01-01','yyyy-mm-dd') from dual)
6 select * from b
7 order by dt asc
8 / ID DT
---------- -----------
3 2005-12-25
5 2010-05-21
4 2011-04-01
1 2014-01-01
--
select *
from a,b
where a.id=b.id
order by b.dt asc; ID A1 A2 ID DT
---------- ---------- -------- ---------- -----------
3 china america 3 2005-12-25
4 CF DNF 4 2011-04-01
1 bbc cnn 1 2014-01-01
--
select a.*
from a,b
where a.id=b.id
order by b.dt asc; ID A1 A2
---------- ---------- --------
3 china america
4 CF DNF
1 bbc cnn
SQL> with a as(
2 select 1 id,'bbc' a1,'cnn' a2 from dual union all
3 select 2,'basketball','football' from dual union all
4 select 3,'china','america' from dual union all
5 select 4,'CF','DNF' from dual)
6 ,b as(
7 select 4 id,to_date('2011-04-01','yyyy-mm-dd') dt from dual union all
8 select 3,to_date('2005-12-25','yyyy-mm-dd') from dual union all
9 select 5,to_date('2010-05-21','yyyy-mm-dd') from dual union all
10 select 1,to_date('2014-01-01','yyyy-mm-dd') from dual)
11 select a.*
12 from a,b
13 where a.id=b.id
14 order by b.dt asc; ID A1 A2
---------- ---------- --------
3 china america
4 CF DNF
1 bbc cnn