Fixed type error in sql statement