darwinLabs Interview Question

How I would a SQL for a specific scenario