AT&T interview question

Write a sql query that gets