Capgemini interview question

SQL & PostGre DB with query explanation