Menu
hardLazada · window

Second most expensive product per category

Lazada wants the runner-up priced item in each category.

For each category in products, return the category and the second highest price in that category as second_highest. Assume no two products in a category share the same price.

Schema

products
idINT
categoryTEXT
priceNUMERIC(10,2)

Example input

products
↑ 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.