Datametica interview question

Write a SQL query on given table.