
                
                
                SELECT 
                eu.EvnUsluga_id as "EvnUsluga_id",
                ec.EvnClass_SysNick as "EvnClass_SysNick",
                uc.UslugaComplex_Code as "UslugaComplex_Code",
                uc.UslugaComplex_Name as "UslugaComplex_Name",
                to_char(eu.EvnUsluga_setDT, 'dd.mm.yyyy') as "EvnUsluga_setDate",
                eu.EvnUsluga_Kolvo as "EvnUsluga_Count",
                eps.EvnPS_NumCard as "EvnPS_NumCard",
                msf.Person_Fio as "MedPersonalFIO",
                ls.LpuSection_Name as "LpuSection_Name"
                ,
                case
                    when ec.EvnClass_SysNick = 'EvnUslugaCommon' then 'Общая услуга'
                    when ec.EvnClass_SysNick = 'EvnUslugaOper' then 'Оперативная услуга'
                    else ''
                end as "EvnClass_Name"
            
                
                FROM
                
                v_EvnUsluga eu
                inner join v_UslugaComplex uc on uc.UslugaComplex_id = eu.UslugaComplex_id
                inner join v_EvnClass ec on ec.EvnClass_id = eu.EvnClass_id
                inner join v_EvnPS eps on eps.EvnPS_id = eu.EvnUsluga_rid
                inner join v_LpuSection ls on ls.LpuSection_id = eu.LpuSection_uid
                left join v_MedStaffFact msf on msf.MedStaffFact_id = eu.MedStaffFact_id
                 WHERE 
                eu.Lpu_id = '13101856'
                and eu.EvnUsluga_setDT is not null
                and eu.EvnUsluga_setDate between '2022-05-05' and '2022-05-05'
                and eu.LpuSection_uid = '890101000000779' and eu.EvnClass_SysNick in ('EvnUslugaCommon', 'EvnUslugaOper')
                
                
                        ORDER BY
                            
                eu.EvnUsluga_id
                
                OFFSET 0 ROWS
                FETCH NEXT 50 ROWS ONLY
                
