Risolto, l'errore non era nella query che ho postato, ma nella query che mi conta i record ,grazieeeeeeeeeeeeeeee