Modified some sql