Fix some sql compositions