冲账业务查询sql

select  tt.*
  from (select p0.*,rownum as rownum1
          from (select *
                  from (select *
                          from (select a.id as "id",
                                       a.transno as "newTransNo",
                                       a.transactiontype as "transactionType",
                                       transactiontype as "tranType",
                                       a.extaccountno as "pExtAccountNo",
                                       a.extclientname as "pExtClientName",
                                       b.accountno as "rAccountNo",
                                       b.acountname as "rAcountName",
                                       a.amount as "amount",
                                       to_char(a.interestStartDate,
                                               'yyyy-MM-dd') as "interestStartDate",
                                       a.status as "status",
                                       a.officeid as "officeId",
                                       a.currencyid as "currencyId",
                                       to_char(a.executeDate, 'yyyy-MM-dd') as "executeDate",
                                       a.ORIGINTRANSNO as "transNo",
                                       a.SUUID as "SUUID",
                                       a.modifydate as "modifydate"
                                  from sett_transcurrentdeposit a,
                                       sett_account             b
                                 where a.receiveaccountid = b.id(+)
                                   and a.transactiontype = 1
                                   and a.originTransNo is not null
                                   and a.status != 0
                                   and a.executeDate >= to_date('2019-09-09', 'yyyy-MM-dd')
                                  -- and a.inputUserId = ?
                                union
                                select a.id as "id",
                                       a.transno as "newTransNo",
                                       a.transactiontype as "transactionType",
                                       a.transactiontype as "tranType",
                                       b.accountno as "pExtAccountNo",
                                       b.acountname as "pExtClientName",
                                       a.extaccountno as "rAccountNo",
                                       a.extclientname as "rAcountName",
                                       a.amount as "amount",
                                       to_char(a.interestStartDate,
                                               'yyyy-MM-dd') as "interestStartDate",
                                       a.status as "status",
                                       a.officeid as "officeId",
                                       a.currencyid as "currencyId",
                                       to_char(a.executeDate, 'yyyy-MM-dd') as "executeDate",
                                       a.ORIGINTRANSNO as "transNo",
                                       a.SUUID as "SUUID",
                                       a.modifydate as "modifydate"
                                  from sett_transcurrentdeposit a,
                                       sett_account             b
                                 where a.payaccountid = b.id(+)
                                   and a.transactiontype = 2
                                   and a.originTransNo is not null
                                   and a.status != 0
                                   and a.executeDate >= to_date('2019-09-09', 'yyyy-MM-dd')
                                   --and a.inputUserId = ?
                                union
                                select a.id,
                                       a.transno as "newTransNo",
                                       a.transactiontype as "transactionType",
                                       a.transactiontype as "tranType",
                                       b.accountno as "pExtAccountNo",
                                       b.acountname as "pExtClientName",
                                       b1.accountno as "rAccountNo",
                                       b1.acountname as "rAcountName",
                                       a.amount as "amount",
                                       to_char(a.interestStartDate,
                                               'yyyy-MM-dd') as "interestStartDate",
                                       a.status as "status",
                                       a.officeid as "officeId",
                                       a.currencyid as "currencyId",
                                       to_char(a.executeDate, 'yyyy-MM-dd') as "executeDate",
                                       a.ORIGINTRANSNO as "transNo",
                                       a.SUUID as "SUUID",
                                       a.modifydate as "modifydate"
                                  from sett_transcurrentdeposit a,
                                       sett_account             b,
                                       sett_account             b1
                                 where a.payaccountid = b.id
                                   and a.receiveaccountid = b1.id
                                   and a.transactiontype = 3
                                   and a.originTransNo is not null
                                   and a.status != 0
                                   and a.executeDate >= to_date('2019-09-09', 'yyyy-MM-dd')
                                   --and a.inputUserId = ?
                                union
                                select a.id,
                                       a.transno as "newTransNo",
                                       a.transactiontype as "transactionType",
                                       a.transactiontype as "tranType",
                                       b.accountno as "pExtAccountNo",
                                       b.acountname as "pExtClientName",
                                       b1.accountno as "rAccountNo",
                                       b1.acountname as "rAcountName",
                                       a.amount as "amount",
                                       to_char(a.interestStartDate,
                                               'yyyy-MM-dd') as "interestStartDate",
                                       a.status as "status",
                                       a.officeid as "officeId",
                                       a.currencyid as "currencyId",
                                       to_char(a.executeDate, 'yyyy-MM-dd') as "executeDate",
                                       a.ORIGINTRANSNO as "transNo",
                                       a.SUUID as "SUUID",
                                       a.modifydate as "modifydate"
                                  from sett_transcurrentdeposit a,
                                       sett_account             b,
                                       sett_account             b1
                                 where a.payaccountid = b.id
                                   and a.receiveaccountid = b1.id
                                   and a.transactiontype = 511
                                   and a.originTransNo is not null
                                   and a.status != 0
                                   and a.executeDate >= to_date('2019-09-09', 'yyyy-MM-dd')
                                   --and a.inputUserId = ?
                                union
                                select st.id as "id",
                                       se.newtransno as "newTransNo",
                                       st.transtypeid as "transactionType",
                                       st.transtypeid as "tranType",
                                       b.accountno as "pExtAccountNo",
                                       b.acountname as "pExtClientName",
                                       null as "rAccountNo",
                                       null as "rAcountName",
                                       st.totalamount as "amount",
                                       to_char(st.interestStartDate,
                                               'yyyy-MM-dd') as "interestStartDate",
                                       st.statusid as "status",
                                       st.officeid as "officeId",
                                       st.currencyid as "currencyId",
                                       to_char(st.executeDate, 'yyyy-MM-dd') as "executeDate",
                                       se.origintransno as "transNo",
                                       st.coluuid as "SUUID",
                                       st.modifytime as "modifydate"
                                  from sett_transpayroll st,
                                       sett_account      b,
                                       sett_transreverse se
                                 where st.payaccountid = b.id
                                   and st.transno = se.newtransno
                                   and st.statusid != 0
                                   and st.executeDate >=
                                       to_date('2019-09-09', 'yyyy-mm-dd')) re
                         where 1 = 1
                           and re."officeId" || '_' || re."currencyId" in
                               (select offcurr
                                  from V_P_USER_OFFICE_CURRENCY
                                 where userid = 309)
                         order by 17 DESC)
                 where 1 = 1
                 order by rownum asc) p0)tt
 where rownum1 > 0
   and rownum1 <= 1000
 

发布了66 篇原创文章 · 获赞 19 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/hwq293/article/details/103732130
今日推荐