Fix SQL bug statement ends with ''