select res select count from tmeasurements where machine_event_id res

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
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