Zendesk interview question

Convert the following active record to SQL