Grab interview question

Write a SQL query to produce following result