c'è un problema nella query, hai provato a stamparla ed eseguirla direttamente nel database?