Wayfair Interview Question

How to write SQL for a given problem statement.