Autumn Offers - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
The COALESCE() function
7. Using COALESCE() in calculations
The GREATEST() & LEAST() functions
The NULLIF() function
Summary

Instruction

Awesome! You can also use COALESCE() in calculations:

SELECT COALESCE(price, 0) * 1.05
FROM product;

This will return each product's price times 1.05 (if there's a price value) or a zero if the price is NULL.

Exercise

The company is giving a 10% discount on all prices for in its first market shop. Show the names of all products, their current price (market1_price), and the new discounted price. Name the new column new_market1_price. If there is no price, show 0.0.

Stuck? Here's a hint!

Use this expression to get the right price:

COALESCE(market1_price * 0.9, 0.0)