select res.*,
(
select count(*) from tmeasurements m
where m.machine_event_id = res.machine_event_id
and exist
(
select tt.point_id from #TEMPTABLE_VIBRO_CHANNELS tt
where tt.point_id = m.point_id and tt.CHANNEL_SETTING_ID = m.CHANNEL_SETTING_ID and tt.PARAMETER_SETTING_ID = m.PARAMETER_SETTING_ID
)
) as cnt1
from #TEMPTABLE_RESULT res