final additions to the SQL queries