Pergunta de entrevista da empresa Epsilon

SQL, DBMS, logic building, one coding question.