select distinct a.id, a.value, (case when a.id_pc is not null then b.value when a.id_monitor is not null then c.value when a.id_printer is not null then d.value else null end) inv_num
from task a left join pc b on (a.id_pc=b.id)
left join monitor c on (a.id_monitor=c.id)
left join printer d on (a.id_printer=d.id)