Verisk interview question

Write db script with the given situation.