标签:
工作中遇到一个需求 无采购多次付款申请列表。用到的sql如下
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,
‘发起付款‘ 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 = ‘有合同‘
and a.url_type_code = ‘0‘
order by B.STARTTIME desc
这个就是根据流程实例workid分组之后,然后按照流程实例版本号进行倒序排列,而此函数的值就是内部排序后的顺序编号,
where后边取rownumber=‘1‘指的就是最新的版本号了。
注:tw_horizon_author 为流程轨迹表
标签:
原文地址:http://www.cnblogs.com/zhouyanan/p/5761757.html