
Explore a dataset of world populations produced by the World Bank, and learn how to sort and limit your query results using the ORDER BY and LIMIT clauses.
When working with large datasets, it's essential to sort and limit your results. The ORDER BY clause allows you to sort results in ascending (ASC) or descending (DESC) order, while the LIMIT clause restricts the number of rows returned.
Try the following queries to explore world population data:
SELECT country, population FROM countries ORDER BY population DESC LIMIT 5
SELECT country FROM countries ORDER BY country ASC
SELECT country, population FROM countries ORDER BY population ASC LIMIT 10
In this lesson, we've learned how to use ORDER BY to sort query results and LIMIT to restrict the number of rows returned. These clauses are essential for working with large datasets and presenting data in a meaningful way.