La query funziona benissimo rispetto ai tuoi requisiti. Sono i tuoi dati che non vanno bene.
Mi spiego. Vuoi l'id della tabella nel risultato ma gli id nella tua tabella sono tutti diversi.
Quindi o hai una chiave univoca id/id_gruppo/tipo o hai una chiave id_gruppo/tipo. Nell'ultimo caso non puoi avere l'id nel risultato.
Primo caso
codice:
select A.id, A.idgruppo, A.testo, B.testo, C.testo
from tab2 A
inner join tab2 B on A.id = B.id and A.idgruppo = B.idgruppo
inner join tab2 C on A.id = C.id and A.idgruppo = C.idgruppo
where A.tipo = 'titolo' and B.tipo = 'img' and C.tipo = 'desc'
Secondo caso :
codice:
select A.idgruppo, A.testo, B.testo, C.testo from tab2 A
inner join tab2 B on A.idgruppo = B.idgruppo
inner join tab2 C on A.idgruppo = C.idgruppo
where A.tipo = 'titolo' and B.tipo = 'img' and C.tipo = 'desc'