Menu▾
hardPetronas · mathBasic

Blended cost per litre

Petronas buys fuel from different suppliers in batches of different sizes and different prices, then sells it as one undifferentiated product at the pump. Finance wants the true blended cost per litre for each fuel grade — not a simple average of the batch prices, which ignores that a 50,000-litre batch and a 500-litre batch shouldn't count equally.

From fuel_batches, return each grade, and blended_cost_per_litre — the volume-weighted average cost per litre (total cost across all batches of that grade, divided by total litres of that grade), rounded to 4 decimal places. Order the output by grade.

Schema

▸fuel_batches
batch_idINT
gradeTEXT
litresNUMERIC(12,2)
cost_per_litreNUMERIC(10,4)

Basic

The example input, expected output, and walkthrough for this question unlock with a Basic plan.

↑ Read the question

Basic

This is a Basic question

Premium practice questions unlock with a Basic plan. The full solution, expected output, and grading are available to Basic members.

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.