Oracle analytic function rank (), row_number (), LAG (), etc. _oracle
Source: Internet
Author: User
Row_number () over (PARTITION by COL1 ORDER by COL2)
Represents a grouping based on COL1, sorted by COL2 within a group
This value represents the sequential numbering of each group's internal sorting (a sequential unique within the group)
Rank () is similar, but rank is ranked in the same way as the rank, can be ranked 2 first place after the 3rd place
LAG indicates that after grouping, the next record in the group is less than the difference between the previous record and the first can return NULL
The most detailed, Btw:expert one on one, and a lot of related features, the document looks more laborious
Row_number () and rownum are similar, more powerful (can be sorted from 1 in each group)
Rank () is a jump sort, with two second names followed by fourth place (also within each group)
Dense_rank () L is a sequential sort, with two second names still followed by third.
In contrast, Row_number has no duplicate values.
Lag (ARG1,ARG2,ARG3):
Arg1 is an expression returned from another row
Arg2 is the offset of the current row partition that you want to retrieve. is a positive offset, which retrieves the number of previous rows backwards.
Arg3 is the value that is returned when the number of ARG2 represents exceeds the range of the grouping.
sql> set pagesize 100;
Sql> select rownum from emp;
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.