Capgemini interview question

Coding question and SQL query