Lazada interview question

How do you code this SQL question