American Express interview question

sql queries as some puzzles