AT&T interview question

asked to build a SQL queries