[ANALYTICS] Corrections in the sql query