select le.id, lead_id,
(select value from wp_rg_lead_detail f where f.lead_id = l.lead_id and f.field_number = 35 ) sozd,
(select value from wp_rg_lead_detail f where f.lead_id = l.lead_id and f.field_number = 39 ) nomer
from wp_rg_lead_detail l, wp_rg_lead le
WHERE l.form_id = '8'
AND l.lead_id = le.id
AND status='active'
group by lead_id