Modify SQL to reflect the latest data model