
                with mv as (select dbo.tzGetDate() - interval '366 days' as nowDateM1y)
                select RESD.Evn_id as "Evn_id"
                from
                    v_RegistryESData RESD
                    left join v_RegistryEs RE on RE.RegistryES_id = RESD.RegistryES_id
                where
                    EvnStick_Num = '910115069650'
                    and RE.RegistryES_updDT >= (select nowDateM1y from mv)
                    and (
                        coalesce(RE.RegistryEsStatus_id, 0) in (0, 11, 12, 13, 14)
                        or RESD.RegistryEsDataStatus_id = 1
                    )
                limit 1
            
