Zendesk Interview Question

Convert the following active record to SQL