Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
The COALESCE() function
The GREATEST() & LEAST() functions
10. The LEAST() function
The NULLIF() function
Summary

Instruction

Similar to the GREATEST() function there is the LEAST() function. Here is the query using it:

SELECT
  id,
  LEAST(market1_price, market2_price) AS smallest_price
FROM product;

This query returns the lowest price between shop 1 and shop 2.

Exercise

Find the smallest price of each product among prices in all three shops. Select ID, the name of the product, and the smallest price as the smallest_price column.

Stuck? Here's a hint!

Use this expression:

LEAST(market1_price, market2_price, market3_price) AS smallest_price