ORACLE ROW_NUMBER()

来源:互联网 发布:阴阳师辅助软件 编辑:程序博客网 时间:2024/04/29 20:17
ROW_NUMBER()【语法】ROW_NUMBER() OVER (PARTITION BY COL1 ORDER BY COL2) 【功能】表示根据COL1分组,在分组内部根据 COL2排序,而这个值就表示每组内部排序后的顺序编号(组内连续的唯一的) row_number() 返回的主要是“行”的信息,并没有排名【参数】【说明】Oracle分析函数主要功能:用于取前几名,或者最后几名等【示例】表内容如下:name | seqno | descriptionA | 1 | testA | 2 | testA | 3 | testA | 4 | testB | 1 | testB | 2 | testB | 3 | testB | 4 | testC | 1 | testC | 2 | testC | 3 | testC | 4 | test我想有一个sql语句,搜索的结果是 A | 1 | testA | 2 | testB | 1 | testB | 2 | testC | 1 | testC | 2 | test实现: select name,seqno,description from(select name,seqno,description,row_number() over (partition by name order by seqno) idfrom table_name) where id<=3;
0 0
原创粉丝点击