codice:
select 
d.id_domanda,
d.domanda,
max(case when r.id_risposte = 1 then r.risposta else null end) as risposta1,
max(case when r.id_risposte = 2 then r.risposta else null end) as risposta2,
max(case when r.id_risposte = 3 then r.risposta else null end) as risposta3,
max(case when r.id_risposte = 4 then r.risposta else null end) as risposta4
from tab_domande as d
left join tab_risposte as r
on d.id_domanda = r.id_domanda
group by d.id_domanda