请oracle高手指点

[复制链接]
查看11 | 回复3 | 2008-12-22 10:47:02 | 显示全部楼层 |阅读模式
code
serialno

A1
1

A1
2

A1
3

A1
5



B1
2

B1
3

B1
4



我要A1和B1的前2条记录.

回复

使用道具 举报

千问 | 2008-12-22 10:47:02 | 显示全部楼层
select code,serialno from (select code,serialno,row_number()over(partition by code order by serialno) r from table_name)where r<=2...
回复

使用道具 举报

千问 | 2008-12-22 10:47:02 | 显示全部楼层
select*from (select code ,serialno , dense_rank() over (partition by c1 order by rowid) r from t )where r<=2...
回复

使用道具 举报

千问 | 2008-12-22 10:47:02 | 显示全部楼层
select * from table_name where code ='A1' and rownum<=2 union allselect * from table_name where code ='B1' and rownum<=2...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行