updated sql for the previous 3 commits.