我需要查询结果是001 001 ibm
002 00001 sun还有这个结果不清晰,为什么是002 00001 sun 而不要002 002 sun.
002 00001 sun还有这个结果不清晰,为什么是002 00001 sun 而不要002 002 sun.
解决方案 »
- regexp_like 能不能表达 > <等条件
- 求解释~~~~~~~~~~
- 请问一个批量插入数据的问题,小弟刚入门,请多指教
- asp连接oracle报错rosoft OLE DB Provider for ODBC Drivers (0x80004005)问题求助!
- 用 IMP 导入数据的问题
- oracel 9i的init.ora文件在哪儿啊?
- @@@@@@@@ 这个语句能不能优化下 @@@@@@@@
- 新年好啊!请教各位高手一个问题?
- oracle 中有没有CONVERT此函数?具体怎么用?
- 请教以下:网上有没有什么容易一点的oracle教程看?书店里面的oracle好书太少了:(
- 各位大侠,表空间转移问题??
- 请教高手!oracle怎样设置连接时间
002 002 sun
002 00001 sun
这两个数据的code1(002) 都在B表中的code1中,所以这两条记录都会被查询出来
------------------------
我需要查询结果是001 001 ibm
002 00001 sun还有这个结果不清晰,为什么是002 00001 sun 而不要002 002 sun.
002 00001 sun
这两行的区别仅仅是行号不同吗,‘002’和‘00001’的选择有什么方法吗
(
select aa.code1,aa.code2,aa.name,row_number()
over (partition by aa.code1 order by aa.code2) top1 from aa,bb where aa.code1=bb.code1
)
where top1 <= 1
/
-------- -------- --------
001 001 IBM
002 002 SUN
002 00001 SUN
003 003 LEGENDSQL> select * from bb;CODE1 DATESTR
-------- --------
001 A
002 BSQL> select code1,code2,name from
2 (
3 select aa.code1,aa.code2,aa.name,row_number()
4 over (partition by aa.code1 order by aa.code2) top1
5 from aa,bb where aa.code1=bb.code1
6 )
7 where top1 <= 1
8 /CODE1 CODE2 NAME
-------- -------- --------
001 001 IBM
002 00001 SUN
select a.code1,a.code2,a.name from aa a,
(select max(x.rowid) myrowid from aa x,bb y
where x.code1=y.code1 group by x.code1) b
where a.rowid=b.myrowid
/