Lazada Interview Question

How do you code this SQL question