Menu

Line totals after a percentage discount

For each booking line item, compute the total after applying a percentage discount:

quantity × unit_price × (1 − discount_pct / 100)

Return item and line_total, rounded to 2 decimal places.

Schema

booking_items
idINT
itemTEXT
quantityINT
unit_priceNUMERIC
discount_pctINT

Example input

booking_items
↑ Read the question

The interviewer's next question

Finance wants to see the discount itself, not just the discounted total: for each item, return item and discount_amount — how much money the discount actually saved, rounded to 2 decimals.

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

See Basic plans

RM 25/mo · cancel anytime

Traveloka wants one number for the whole booking: return a single row with order_total, the sum of every line's discounted total, rounded to 2 decimals.

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.