1plusX Interview Question

How would you create an SQL query for this...