
				
				
				SELECT 
				M.Evn_id as "Evn_id",
				M.Message_id as "Message_id",
				M.Message_pid as "Message_pid",
				to_char(M.Message_setDT, 'DD.MM.YYYY') || ' ' || to_char(M.Message_setDT, 'HH24:MI') as "Message_setDT",
				M.UserSend_ID as "UserSend_ID",
				M.Message_Subject as "Message_Subject",
				COALESCE(M.Message_Text, '') as "Message_Text",

				
			MR.Message_isRead as "Message_isRead",
			MR.MessageRecipient_id as "MessageRecipient_id",
			MR.UserRecipient_id as "UserRecipient_id",
			MR.Message_isFlag as "Message_isFlag",
		
				M.NoticeType_id as "NoticeType_id",
				E.EvnClass_Name as "EvnClass_Name",
				E.PersonEvn_id as "PersonEvn_id",
				E.Server_id as "Server_id",
				E.Evn_rid as "Evn_rid",
				E.EvnClass_SysNick as "EvnClass_SysNick",
				rEvn.EvnClass_SysNick as "EvnClass_rSysNick",
				E.Person_id as "Person_id",
				P.Person_Fio as "Person_Fio",
				exml.EvnXml_id as "EvnXml_id" 
				
				FROM  
				
				msg.v_Message M 
				left join msg.v_MessageLink ML on ML.Message_id = M.Message_id

				--left join msg.v_NoticeType NT  on NT.NoticeType_id = M.NoticeType_id

				left join msg.v_MessageRecipient MR  on MR.Message_id = M.Message_id
				left join pmUserCache MP  on MP.PMUser_id = '392141936941'

				left join v_Evn E  on E.Evn_id = M.Evn_id

				left join v_Evn rEvn  on rEvn.Evn_id = E.Evn_rid

				left join v_Person_all P  on P.Person_id=E.Person_id and P.PersonEvn_id=E.PersonEvn_id
				left join v_Evnxml exml on e.Evn_rid = exml.Evn_id
				left join msg.v_messagerecipient vmr on (M.message_id = vmr.message_id and vmr.userrecipient_id = '392141936941')

				 WHERE 
				
				 M.Evn_id is not null and E.EvnClass_SysNick is not null and M.UserSend_ID = 0  and MR.UserRecipient_id = '392141936941' and M.Message_isSent is not null AND lower(P.Person_Fio) LIKE 'бженникова светлана х' || '%' 
				
				
						ORDER BY 
							
				MR.Message_isRead desc,
				M.Message_setDT desc
				
				OFFSET 0 ROWS		
				FETCH NEXT 10 ROWS ONLY 
				
