Turn and turn--oracle and sort by time to take the first one

Source: Internet
Author: User
Select  t.* from     (select a. *, Row_number () over (partition by required to group fields order by update time desc) RW from             table a) t    = 1  

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

The difference with rownum is that when sorting with rownum, the result set is first added to a fake rownum and then sorted, and this function sorts and then calculates the line number after it contains the sort clause.

Row_number () is about the same as rownum, which is a bit more powerful (it can be sorted from 1 within each grouping).

Rank () is a jumping sort, with two second names followed by fourth (also within each group)

Dense_rank () is also a sequential sort, with two second names still followed by third place. In contrast, Row_number does not have duplicate values.

Oracle analytic function row_number (), returns an integer value (>=1);

Turn and turn--oracle and sort by time to take the first one

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.