Oracle lead (), Lag ()

Source: Internet
Author: User

The lead () is the next record in the current order, and the relative lag () is the previous row of records in the current order

Syntax structure: lead (value_expr [, Offset][,default]) over ([Query_partition_clause] ORDER by Order_by_clause) parameter description: value_expr A value expression, usually a field or an expression. The value_expr itself does not support parsing functions, which means that the lead does not support multiple calls. Offset offsets, should be very familiar with the mathematical concept, or is a relative offset, the table to open the current row of the offset line, if offset is an integer is indicated by the order of the first nth row, if the negative number is the nth row. If you do not provide this parameter, it is default to 1.default default value, if not found, should return what value meaning, somewhat similar to NVL (Col,value). If it is not set and cannot be found, then the return nullover is understood to be within the scope of a result set, and if the subsequent partition by is empty, then it is within the scope of the current result set. The Query_partition_clause partition statement, the statement that partitions the result collection, is optional, if not all of a partition. Order_by_clause Sort statement must be required, shape as order by xxx Desc/asc exp:select a.*, Lag (name,1) over (order by id desc) lags from T MP A

Oracle lead (), Lag ()

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.