Fixed error with sql