Merkle interview question

Asked to write sql queries for given usecase