App Grid with sql and sub queries

Hello,
i have an app grid based on a sql with join tables and sub queries . If i execute this query on mysql console it works but in scriptcase doesn’t work . The system can’t retrieve the fields of the grid.
If delete the sub queries it works also in Scriptcase

This is the sql.

select a.id,a.cognome,a.nome,c.id,c.id_anno,c.quota,c.nota,c.data_prevista_inc
from cs_corrispondenti a,cs_corrispondenti_quote b,cs_circoli_quote c
where
a.tipo_cor=‘S’ and
a.id=b.id_cor and
c.id=b.id_quota and
(
(c.quota>(select sum(d.valore_segno) from cs_movimenti d where
d.id_cor is not null and d.id_anno_quota is not null and d.id_cor=a.id and d.id_anno_quota=c.id)) or
(0=(select count(*) from cs_movimenti d where
d.id_cor is not null and d.id_anno_quota is not null and d.id_cor=a.id and d.id_anno_quota=c.id ))
)
order by a.cognome,a.nome,c.id_anno,c.id

Regards
Gianpaolo