NatWest Group interview question

Complete python and sql challenge