Barclays interview question

Python quaries and SQL quaries and fill the gaps.