Facebook
From Corrupt Hornbill, 3 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 69
  1.                         select
  2.                                 R.Registry_id as "Registry_id",
  3.                                 R.RegistryType_id as "RegistryType_id",
  4.                                 RS.RegistryStatus_id as "RegistryStatus_id",
  5.                                 RS.RegistryStatus_SysNick as "RegistryStatus_SysNick",
  6.                                 R.Registry_IsActive as "Registry_IsActive",
  7.                                 coalesce(R.Registry_IsNeedReform, 1) as "Registry_IsNeedReform",
  8.                                 RTrim(R.Registry_Num) as "Registry_Num",
  9.                                 to_char(R.Registry_insDT, 'dd.mm.yyyy') as "Registry_insDT",
  10.                                 to_char(R.Registry_accDate, 'dd.mm.yyyy') as "Registry_accDate",
  11.                                 to_char(R.Registry_begDate, 'dd.mm.yyyy') as "Registry_begDate",
  12.                                 to_char(R.Registry_endDate, 'dd.mm.yyyy') as "Registry_endDate",
  13.                                 R.Lpu_id as "Lpu_id",
  14.                                 R.Registry_xmlExportPath as "Registry_xmlExportPath",
  15.                                 DC.DispClass_id as "DispClass_id",
  16.                                 DC.DispClass_Name as "DispClass_Name",
  17.                                 R.PayType_id as "PayType_id",
  18.                                 PT.PayType_Name as "PayType_Name",
  19.                                 PT.PayType_SysNick as "PayType_SysNick",
  20.                                 R.KatNasel_id as "KatNasel_id",
  21.                                 KN.KatNasel_Name as "KatNasel_Name",
  22.                                 KN.KatNasel_SysNick as "KatNasel_SysNick",
  23.                                 R.OrgRSchet_id as "OrgRSchet_id",
  24.                                 R.OrgSMO_id as "OrgSMO_id",
  25.                                 R.Org_mid as "Org_mid",
  26.                                 R.Registry_IsRepeated as "Registry_IsRepeated",
  27.                                 R.Registry_IsLocked as "Registry_IsLocked",
  28.                                 case when R.Registry_IsRepeated = 2 then 'Исправительный' else 'Основной' end as "RegistryUnionText",
  29.                                 case when KN.KatNasel_Code = 1 then OS.OrgSMO_Name else 'ТФОМС КБР' end as "PayText",
  30.                                 case when R.Registry_IsZNO = 2 then 'true' else 'false' end as "Registry_IsZNO",
  31.                                 LB.LpuBuilding_Name as "LpuBuilding_Name",
  32.                                 coalesce(R.Registry_RecordCount, 0) as "Registry_Count",
  33.                                 coalesce(R.Registry_ErrorCount, 0) as "Registry_ErrorCount",
  34.                                 RegistryErrorCom.RegistryErrorCom_IsData as "RegistryErrorCom_IsData",
  35.                                 RegistryError.RegistryError_IsData as "RegistryError_IsData",
  36.                                 RegistryNoPolis.RegistryNoPolis_IsData as "RegistryNoPolis_IsData",
  37.                                 RegistryErrorTFOMS.RegistryErrorTFOMS_IsData as "RegistryErrorTFOMS_IsData",
  38.                                 RegistryNoPay.RegistryNoPay_IsData as "RegistryNoPay_IsData",
  39.                                 coalesce(R.Registry_Sum, 0.00) as "Registry_Sum",
  40.                                 0.00 as "Registry_SumNoErr",
  41.                                 0.00 as "Registry_SumPaid",
  42.                                 case when RQ.RegistryQueue_id is not null then 1 else 0 end as "Registry_IsProgress",
  43.                                 '' as "Registry_lastExpDate",
  44.                                 to_char(R.Registry_updDT, 'dd.mm.yyyy hh24:mi:ss') as "Registry_updDate",
  45.                                 to_char(RQH.RegistryQueueHistory_endDT, 'dd.mm.yyyy hh24:mi:ss') as "ReformTime",
  46.                                 RGT.RegistryGroupType_Name as "RegistryGroupType_Name",
  47.                                 RGT.RegistryGroupType_Code as "RegistryGroupType_Code",
  48.                                 RCS.RegistryCheckStatus_id as "RegistryCheckStatus_id",
  49.                                 RCS.RegistryCheckStatus_Code as "RegistryCheckStatus_Code",
  50.                                 RCS.RegistryCheckStatus_Name as "RegistryCheckStatus_Name",
  51.                                 case when RS.RegistryStatus_SysNick = 'paid' then '2' else '1' end as "Registry_IsPaid",
  52.                                 OS.OrgSMO_Nick as "OrgSMO_Nick",
  53.                                 '' as "Error_Message"
  54.                         from r68.v_Registry R
  55.                                 left join v_RegistryGroupType RGT on RGT.RegistryGroupType_id = R.RegistryGroupType_id
  56.                                 left join v_RegistryCheckStatus RCS on RCS.RegistryCheckStatus_id = R.RegistryCheckStatus_id
  57.                                 left join v_DispClass DC on DC.DispClass_id = R.DispClass_id
  58.                                 left join v_PayType PT on PT.PayType_id = R.PayType_id
  59.                                 left join v_KatNasel KN on KN.KatNasel_id = R.KatNasel_id
  60.                                 left join v_LpuBuilding LB  on LB.LpuBuilding_id = R.LpuBuilding_id
  61.                                 left join v_OrgSMO OS on OS.OrgSMO_id = R.OrgSMO_id
  62.                                 left join RegistryStatus RS on RS.RegistryStatus_id = R.RegistryStatus_id
  63.                                 left join lateral(
  64.                                         select
  65.                                                 RegistryQueue_id
  66.                                         from r68.v_RegistryQueue
  67.                                         where Registry_id = R.Registry_id
  68.                                         limit 1
  69.                                 ) RQ on true
  70.                                 left join lateral(
  71.                                         select
  72.                                                 RegistryQueueHistory_endDT
  73.                                         from r68.RegistryQueueHistory
  74.                                         where Registry_id = R.Registry_id
  75.                                                 and RegistryQueueHistory_endDT is not null
  76.                                         order by RegistryQueueHistory_id desc
  77.                                         limit 1
  78.                                 ) RQH on true
  79.                                 left join lateral(
  80.                                         select case when RE.Registry_id is not null then 1 else 0 end as RegistryErrorCom_IsData
  81.                                         from r68.v_RegistryErrorCom RE
  82.                                         where RE.Registry_id = R.Registry_id
  83.                                         limit 1
  84.                                 ) RegistryErrorCom on true
  85.                                 left join lateral(
  86.                                         select case when RE.Registry_id is not null then 1 else 0 end as RegistryError_IsData
  87.                                         from r68.v_RegistryError RE
  88.                                         where RE.Registry_id = R.Registry_id
  89.                                         limit 1
  90.                                 ) RegistryError on true
  91.                                 left join lateral(
  92.                                         select case when RE.Registry_id is not null then 1 else 0 end as RegistryNoPolis_IsData
  93.                                         from r68.v_RegistryNoPolis RE
  94.                                         where RE.Registry_id = R.Registry_id
  95.                                         limit 1
  96.                                 ) RegistryNoPolis on true
  97.                                 left join lateral(
  98.                                         select case when RE.Registry_id is not null then 1 else 0 end as RegistryErrorTFOMS_IsData
  99.                                         from r68.v_RegistryErrorTFOMS RE
  100.                                         where RE.Registry_id = R.Registry_id
  101.                                         limit 1
  102.                                 ) RegistryErrorTFOMS on true
  103.                                 left join lateral(
  104.                                         select case when RD.Registry_id is not null then 1 else 0 end as RegistryNoPay_IsData
  105.                                         from r68.v_RegistryData RD
  106.                                         where RD.Registry_id = R.Registry_id and RD.Paid_id = 1
  107.                                         limit 1
  108.                                 ) RegistryNoPay on true
  109.                                
  110.                         where
  111.                                 (1=1) and R.Lpu_id = '680101000000001' and R.RegistryType_id = '16' and RS.RegistryStatus_SysNick = 'work'
  112.                         order by
  113.                                 R.Registry_endDate DESC,
  114.                                 RQH.RegistryQueueHistory_endDT DESC
  115.                
  116. execution time: 0.1770761013
  117. fetching time: 0.0000438690
  118. [{"Registry_id":"680101000000581","RegistryType_id":"16","RegistryStatus_id":"3","RegistryStatus_SysNick":"work","Registry_IsActive":"2","Registry_IsNeedReform":"1","Registry_Num":"\u0442\u0435\u0441\u04422","Registry_insDT":"11.12.2020","Registry_accDate":"11.12.2020","Registry_begDate":"01.11.2020","Registry_endDate":"30.11.2020","Lpu_id":"680101000000001","Registry_xmlExportPath":null,"DispClass_id":null,"DispClass_Name":null,"PayType_id":"680101000000008","PayType_Name":"\u041e\u041c\u0421","PayType_SysNick":"oms","KatNasel_id":"680101000000003","KatNasel_Name":"\u0412\u0441\u0435 \u043d\u0430\u0441\u0435\u043b\u0435\u043d\u0438\u0435","KatNasel_SysNick":"all","OrgRSchet_id":null,"OrgSMO_id":null,"Org_mid":null,"Registry_IsRepeated":"1","Registry_IsLocked":null,"RegistryUnionText":"\u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439","PayText":"\u0422\u0424\u041e\u041c\u0421 \u041a\u0411\u0420","Registry_IsZNO":"true","LpuBuilding_Name":null,"Registry_Count":"0","Registry_ErrorCount":"0","RegistryErrorCom_IsData":null,"RegistryError_IsData":null,"RegistryNoPolis_IsData":null,"RegistryErrorTFOMS_IsData":null,"RegistryNoPay_IsData":null,"Registry_Sum":"0.00","Registry_SumNoErr":"0.00","Registry_SumPaid":"0.00","Registry_IsProgress":"0","Registry_lastExpDate":"","Registry_updDate":"11.12.2020 13:44:01","ReformTime":"11.12.2020 13:44:02","RegistryGroupType_Name":null,"RegistryGroupType_Code":null,"RegistryCheckStatus_id":null,"RegistryCheckStatus_Code":null,"RegistryCheckStatus_Name":null,"Registry_IsPaid":"1","OrgSMO_Nick":null,"Error_Message":""},{"Registry_id":"680101000000532","RegistryType_id":"16","RegistryStatus_id":"3","RegistryStatus_SysNick":"work","Registry_IsActive":"2","Registry_IsNeedReform":"1","Registry_Num":"\u0442\u0435\u0441\u0442","Registry_insDT":"10.12.2020","Registry_accDate":"10.12.2020","Registry_begDate":"01.10.2020","Registry_endDate":"31.10.2020","Lpu_id":"680101000000001","Registry_xmlExportPath":null,"DispClass_id":null,"DispClass_Name":null,"PayType_id":"680101000000008","PayType_Name":"\u041e\u041c\u0421","PayType_SysNick":"oms","KatNasel_id":"680101000000003","KatNasel_Name":"\u0412\u0441\u0435 \u043d\u0430\u0441\u0435\u043b\u0435\u043d\u0438\u0435","KatNasel_SysNick":"all","OrgRSchet_id":null,"OrgSMO_id":null,"Org_mid":null,"Registry_IsRepeated":"1","Registry_IsLocked":null,"RegistryUnionText":"\u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439","PayText":"\u0422\u0424\u041e\u041c\u0421 \u041a\u0411\u0420","Registry_IsZNO":"false","LpuBuilding_Name":null,"Registry_Count":"2","Registry_ErrorCount":"0","RegistryErrorCom_IsData":null,"RegistryError_IsData":null,"RegistryNoPolis_IsData":null,"RegistryErrorTFOMS_IsData":null,"RegistryNoPay_IsData":null,"Registry_Sum":"727.04","Registry_SumNoErr":"0.00","Registry_SumPaid":"0.00","Registry_IsProgress":"0","Registry_lastExpDate":"","Registry_updDate":"22.12.2020 15:12:02","ReformTime":"22.12.2020 15:12:40","RegistryGroupType_Name":null,"RegistryGroupType_Code":null,"RegistryCheckStatus_id":null,"RegistryCheckStatus_Code":null,"RegistryCheckStatus_Name":null,"Registry_IsPaid":"1","OrgSMO_Nick":null,"Error_Message":""}]