Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Single-column indexes
Multi-column indexes
Additional options when creating indexes
8. ASC and DESC keywords in indexes – example
Summary

Instruction

Nice work! Here's the index we created in the previous exercise:

CREATE INDEX player_multi_country_points_index
ON player(country ASC, current_points DESC);

It can now be used for the following query:

SELECT
  id,
  country,
  current_points
FROM player
WHERE country IN ('Spain', 'Italy', 'France')
ORDER BY country ASC, current_points DESC;

Note that we added an ORDER BY clause that uses ASC and DESC the same way the index does.

Exercise

Click Next exercise to continue.