Menu▾
hardLazada · window

Second most expensive product per category

Lazada wants the runner-up price point in each category.

For each category in products, return one row with the second-highest distinct price as second_highest. Products may tie on price; a category with fewer than two distinct prices should not appear.

Schema

▸products
idINT
categoryTEXT
priceNUMERIC(10,2)

Example input

↑ Read the question

The interviewer's next question

Good. Now do the same for the THIRD highest price per category, as third_highest — categories with fewer than three products should simply not appear.

Solving follow-ups — the questions an interviewer actually asks next — unlocks with a Basic plan.

See Basic plans

RM 25/mo · cancel anytime

One more: for each category, how much cheaper is the second-highest priced item than the highest, as price_gap?

Solving follow-ups — the questions an interviewer actually asks next — unlocks with a Basic plan.

See Basic plans

RM 25/mo · cancel anytime

Keep going

Company names are trademarks of their respective owners, used here only to describe practice material. mahir_data is not affiliated with, endorsed by, or sponsored by any company named on this site. Terms.