SQL changes based on Corey's suggestions