各位大大:
现在有一表 t 如下:
id,name,type
现在要取每个type下的前10条,根据name排序
请问要怎么写?
sql serv 下的写法有这样一种:
- SQL code
SELECT * FROM ( SELECT rid=ROW_NUMBER() OVER(PARTITION BY type ORDER BY name),* FROM ( SELECT * FROM T ) X ) AS T WHERE rid<=10
那么oracle中要怎么写?谢谢各位!
------解决方案--------------------
- SQL code
SELECT * FROM (SELECT t.*,ROW_NUMBER() OVER(PARTITION BY type ORDER BY name) rid FROM T ) WHERE rid<=10