I am extracting the same informations from three different tables: I need to get all the data in one table grouping the results as in each single query. The query I wrote is the following:

```
SELECT centri_costoricavo.descrizione, movimenti.movimento, sum(totali) FROM 
SELECT centri_costoricavo.descrizione, movimenti.movimento, sum(fa_ce_ca.importo) AS totali FROM fatture, fa_ce_ca,centri_costoricavo, movimenti WHERE fatture.esercizio=3 AND fatture.id_fa=fa_ce_ca.id_fa AND centri_costoricavo.id=fa_ce_ca.centro AND movimenti.id=fa_ce_ca.caus GROUP BY fa_ce_ca.caus AS fatture 
UNION SELECT centri_costoricavo.descrizione, movimenti.movimento, sum(mov_banca.importo) AS totali FROM mov_banca,centri_costoricavo, movimenti,esercizi WHERE centri_costoricavo.id=mov_banca.centro AND movimenti.id=mov_banca.tipo AND mov_banca.data BETWEEN esercizi.start AND esercizi.end AND esercizi.id=3 AND mov_banca.per=2 GROUP BY mov_banca.tipo AS mov_banca 
UNION SELECT centri_costoricavo.descrizione, movimenti.movimento, sum(mov_cassa.importo) AS totali FROM mov_cassa,centri_costoricavo, movimenti,esercizi WHERE centri_costoricavo.id=mov_cassa.centro AND movimenti.id=mov_cassa.tipo AND mov_cassa.data BETWEEN esercizi.start AND esercizi.end AND esercizi.id=3 AND mov_cassa.per=2 GROUP BY mov_cassa.tipo) AS mov_cassa 
GROUP BY movimenti.movimento

```

Trying to execute the query I get the following error: "... the right syntax to use near 'AS mov\_banca UNION (S...". After hours banging my head against the wall I can't see what I am doing wrong. Any help?

Thanks in advance!
Lelio