Accenture interview question

Sql queries for CTE