Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Review
Comparisons with NULL
Functions with NULL
COALESCE to the rescue
18. COALESCE with calculations
NULLIF
Review and practice

Instruction

Good. You can also use COALESCE in calculations in a similar way:

COALESCE(price, 0) * 1.05

The above query will return the price times 1.05 or 0 (0 * 1.05 = 0) if the price is NULL.

Exercise

The company organized a discount campaign on all prices: -10%.

Show the names of all products together with their price and the new prices (name the column new_price). If there is no price, show 0.00 in the column new_price. Round the result to two decimal points.

Stuck? Here's a hint!

To round your price to two decimal points, you can use the ROUND() function in the following way:

ROUND(price, 2)

To get the right price, you can write:

COALESCE(price * 0.9, 0.00)