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