Amazon interview question

Some difficult advanced sql questions