EPAM Systems interview question

SQL Excercise. Write a couple of intermediate queries