select t_cluster.caption as cluster,
   t_well.caption  as well,
   t_well.id_telemetry 
from t_cluster
join t_well on t_well.id_cluster = t_cluster.id  
where t_cluster.caption in ('82', 'к50 Б', 'к8', '6 A') and t_well.id_telemetry is not null
order by cluster , well 

\copy (select "date", "mode", well_depth, bit_depth, hook_weight, hook_weight_idle, axial_load, block_speed, block_position, rotor_speed, rotor_torque, flow, flow_idle, pressure, pressure_idle from t_telemetry_data_saub where id_telemetry = 137) to '/home/asb/export/dump_c_82_w_2533_t_137.csv' DELIMITER ';' CSV header;
