Row_number () function

Source: Internet
Author: User

The job encountered a demand for no purchase multiple payment request list. The SQL used is as follows

Select b.ID,
A.title,
A.bill_number,
A.cost_first_type_name,
A.creator_name,
A.appdate,
A.payment_company_name,
A.supplier_name,
A.contract_amount,
A.have_use_total_amount,
A.have_paid_total_amount,
A.payment_order_amount,
A.payment_count,
' Initiating payment ' as NewViewField1,
B.starttime,
a.ID as Payid
From Ce_corporate_payment A,
Tw_horizon_instance B,
Twr_horizon_instance C,
(SELECT *
From (select A.*,
row_number () over (partition by A.workid ORDER BY a.version Desc) RowNumber
From Tw_horizon_author a)
where RowNumber = 1)D
(SELECT distinct E.dataid, E.userid, E.status
From Td_horizon_user E
where E.userid = ' hz1794a1472031d901473402ca5b6600 '
and e.status = ' 3 ') E
where a.id = C.dataid
and b.id = C.workid
and C.workid = D.workid
and C.workid = E.dataid
and d.flowstatus = 7
and E.userid = ' hz1794a1472031d901473402ca5b6600 '
and A.bill_number = ' 20151103dgfk0103 '
and A.payment_order_amount > A.payment_order
and A.payment_order = 1
and To_number (A.payment_count) < To_number (A.payment_order_amount)
and To_number (A.have_use_total_amount) < To_number (A.contract_amount)
and a.is_have_contract = ' contract '
and A.url_type_code = ' 0 '
ORDER BY b.starttime Desc

This is after grouping according to the process instance workid and then descending by the process instance version number, and the value of this function is the sequential number of the internal sort,

Where you take rownumber= ' 1 ' is the latest version number.

Note: Tw_horizon_author is the process track table

Row_number () function

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.