Group Assignment SQL Query

Continued here: