imp系统运维用到的sql文件版本仓库
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

两个系统栓送数据统计核对sql.txt 3.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. 预支单数据合计
  2. --预支单数量 货款付款/费用付款 /非贸付款 付款类型为预付款 并且 7621-法人单位名称'山东钢铁集团国际贸易有限公司'
  3. --7623 济钢
  4. --并且 排除 费用付款 中费用大类是财务费用类 并且 审核状态 ='待审核' '发送成功' 并且 没有删除
  5. SELECT expanse_report_id ,fours AS fours,COUNT(invoice_code) AS 数量,
  6. SUM(CASE WHEN curcy ='CNY' THEN amt WHEN curcy ='CNY' THEN amt*7.85 ELSE 0 end ) AS 金额
  7. FROM (SELECT DISTINCT SUBSTR(a."expanse_report_id",0,1) AS expanse_report_id,
  8. b.fours AS fours,a.invoice_code,b.amt,b.curcy
  9. FROM SGGMINFT.inf_BCFMP1 a left join SGGMIIP.paymgrctrl b on a.invoice_code=b.fno
  10. WHERE TO_CHAR(a.create_time,'YYYY-MM-DD HH:MI:SS') >= '2026-01-01 00:00:00'
  11. AND TO_CHAR(a.create_time, 'YYYY-MM-DD HH:MI:SS')<= '2026-01-23 12:00:00'
  12. and b.payType like '%预付款%' --and b.fours='SGGM'
  13. and ifnull(b.cateName,'') <> '财务费用类'
  14. and ifnull(impBcStatus,'') in ('待审核','发送成功')
  15. and b.del_flag<>1)
  16. GROUP BY fours ,"expanse_report_id" ;
  17. 报支单数据合计
  18. SELECT expanse_report_id ,fours AS fours,COUNT(invoice_code) AS 数量,
  19. SUM(CASE WHEN curcy ='CNY' THEN amt WHEN curcy ='CNY' THEN amt*7.85 ELSE 0 end ) AS 金额
  20. FROM (SELECT DISTINCT SUBSTR(a."expanse_report_id",0,1) AS expanse_report_id,
  21. b.fours AS fours,a.invoice_code,b.totalAmt AS amt,IFNULL(b.curcy,'CNY') AS curcy
  22. FROM SGGMINFT.inf_BCFMP1 a
  23. left join SGGMIIP.purMultiSettle b on a.invoice_code=b.fno
  24. WHERE TO_CHAR(a.create_time,'YYYY-MM-DD HH:MI:SS') >= '2026-01-01 00:00:00'
  25. AND TO_CHAR(a.create_time, 'YYYY-MM-DD HH:MI:SS')<= '2026-01-23 23:59:59'
  26. --and b.fours='JGGM'
  27. and ifnull(b.impBcStatus,'') in ('待审核','财务审核','财务复核','部分付款','全部付款')
  28. and IFNULL(b.del_flag,'0')<>'1')
  29. GROUP BY fours ,"expanse_report_id" ;
  30. -- 销售发票数据
  31. select
  32. b2.serviceType ,b2.totalAmt,b2.curcy ,
  33. b2.create_by_name 制单人 ,
  34. case when ifnull(b2.fmodalid,0)=36 then '销售发票'
  35. else '' end 模块 ,
  36. a.bill_no
  37. from
  38. (
  39. select distinct bill_no from SGGMINFT.INF_BCFMS1
  40. where proc_status='1'
  41. ) a
  42. left join saleSettle b2 on a.bill_no=b2.fno
  43. where b2.fours='SGGM'
  44. and ifnull(b2.del_flag,0)<>1 ;
  45. ---成本结转
  46. select bccode 账套代码,billType 单据类型 ,count(id) 抛帐数量,curcy,sum(amt) 原币金额 ,sum(cnyamt) 人民币金额
  47. from GwomiCtrl
  48. where impBcStatus='抛账成功' and ifnull(del_flag,0)<>1 and
  49. billType in ('C01001')
  50. group by bccode,billType,curcy
  51. order by bccode,billType,curcy
  52. --通用抛账明细表(暂估)
  53. select
  54. b.bccode ,
  55. b.billType, -- 单据类型
  56. a.curcy,
  57. count(b.id)id ,
  58. sum(case when b.table1 like '%冲销%' then 0-CAST(ROUND( ifnull(a.ntAmt,0)+ ifnull(a.tzamt1,0) ,2) AS DECIMAL(18, 2)) else CAST(ROUND( ifnull(a.ntAmt,0)+ ifnull(a.tzamt1,0) ,2) AS DECIMAL(18, 2)) end) as billSubAmt,-- 单据金额(原币)
  59. sum(case when b.table1 like '%冲销%' AND IFNULL(fcat,0)<>1 then 0-CAST(ROUND( ifnull(a.ntCnyAmt,0)+ ifnull(a.tzamt2,0) ,2)AS DECIMAL(18, 2)) else CAST(ROUND( ifnull(a.ntCnyAmt,0)+ ifnull(a.tzamt2,0) ,2)AS DECIMAL(18, 2)) end ) as billSubAmtRmb-- 单据金额(折人民币)
  60. from Gwomidtl a
  61. left join GwomiCtrl b on a.rid=b.id
  62. where nvl(a.del_flag,0)<>1
  63. and b.impBcStatus='抛账成功'
  64. and a.billType in ('I01001')
  65. and ifnull(b.del_flag,0)<>1
  66. and b.placed='2'
  67. group by b.bccode ,b.billType, a.curcy