Ali Express interview question

Based on a table, write the solution using SQL