
                
                
                SELECT 
                RET.RegistryErrorTFOMS_id as "RegistryErrorTFOMS_id",
                RET.Registry_id as "Registry_id",
                RD.RegistryType_id as "RegistryType_id",
                coalesce(RD.RegistryData_deleted, 1) as "RegistryData_deleted",
                case when RD.Evn_id IS NOT NULL then 1 else 2 end as "RegistryData_notexist",
                RD.Server_id as "Server_id",
                RD.PersonEvn_id as "PersonEvn_id",
                RET.Evn_id as "Evn_id",
                RD.Person_id as "Person_id",
                RD.NumCard as "NumCard",
                RET.RegistryErrorType_Code as "RegistryErrorTfomsType_Code",
                RETT.RegistryErrorTfomsType_Name as "RegistryErrorTfomsType_Name",
                RET.RegistryErrorTfoms_Comment as "RegistryErrorTfoms_Comment",
                '' as "RegistryErrorTFOMSLevel_Name",
                concat_ws(' ', RD.Person_SurName, RD.Person_FirName, RD.Person_SecName) as "Person_FIO",
                to_char(RD.Person_BirthDay, 'dd.mm.yyyy') as "Person_BirthDay",
                RD.SNPolis as "SNPolis",
                OrgSmo.OrgSmo_Nick as "OrgSMO_Name",
                RD.VizitType_Name as "VizitType_Name",
                RD.LpuSection_name as "LpuSection_Name",
                RD.MedPersonal_Fio as "MedPersonal_Fio",
                to_char(RD.Evn_setDate, 'dd.mm.yyyy') as "EvnVizitPL_setDate",
                to_char(RD.Evn_setDate, 'dd.mm.yyyy') as "Evn_setDate",
                to_char(RD.Evn_disDate, 'dd.mm.yyyy') as "Evn_disDate",
                LTRIM(LSP.LpuSectionProfile_Code || ' ' || LSP.LpuSectionProfile_Name) as "LpuSectionProfile_Name",
                RD.n_ksg as "n_ksg",
                RD.Evn_rid as "Evn_rid",
                EvnClass.EvnClass_SysNick as "parentClass",
                RD.EvnClass_id as "EvnClass_id",
                RD.RegistryData_ItogSum as "RegistryData_ItogSum"
                
                
                FROM
                
                r89.v_RegistryErrorTFOMS as RET
                left join r89.v_RegistryData as RD on RD.Registry_id = RET.Registry_id and RD.Evn_id = RET.Evn_id
                left join dbo.v_RegistryErrorTFOMSType as RETT on RETT.RegistryErrorTfomsType_id = RET.RegistryErrorTfomsType_id
                left join v_EvnClass EvnClass on RD.ParentEvnClass_id = EvnClass.EvnClass_id
                left join v_LpuSectionProfile LSP on LSP.LpuSectionProfile_id = RD.LpuSectionProfile_id
                left join v_OrgSmo OrgSmo on OrgSmo.OrgSmo_id = RD.OrgSmo_id
                
                 WHERE 
                RD.Registry_id = '4350' and RET.RegistryErrorTfoms_Comment ilike '428.%'
                
                
                        ORDER BY
                            
                RET.RegistryErrorTfoms_Comment ASC, RET.RegistryErrorTFOMS_id
                
                OFFSET 0 ROWS
                FETCH NEXT 100 ROWS ONLY
                
