fix the sql