Usage of Oracle's Row_number () over (order by COL2 ASC) and Row_number () over (PARTITION by COL1 ORDER by COL2)

Source: Internet
Author: User

Transferred from: https://jingyan.baidu.com/article/9989c74604a644f648ecfef3.html

SELECT row_number () Over (PARTITION by TA. process_instance_id ORDER by NVL (ta.status, ' D ') ASC, NVL (ta.finish_date, Ta.start_date) DESC) as Row_index,
Ta.*
From Warn_task Ta;

2.

Row_number () over (PARTITION by COL1 ORDER by COL2) indicates that sorting is based on COL1 within the grouping according to COL2 grouping, and the value computed by this function represents the sequential number of each set of internally ordered (contiguous unique within the group)

The first is divided into successive groups according to PROCESS_INSTANCE_ID;

A similar approach is Dense_rank () and rank over (),

See also: https://www.cnblogs.com/YuyuanNo1/p/7929543.html

Usage of Oracle's Row_number () over (order by COL2 ASC) and Row_number () over (PARTITION by COL1 ORDER by COL2)

Related Article

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.