RMG Networks Interview Question

SQL query write to get tex