Each dataset is unique along with each of the business use cases for the datasets. That means the processing and transforming of datasets are unique in their own way. However, there are some processing logics that you will frequently run into in the real world. You will learn some of these in the sections in this section.
The DISTINCT and DISTINCT ON Functions
When looking through a dataset, you may be interested in determining the unique values in a column or group of columns. This is the primary use case of the
For example, if you wanted to know all the unique model years in the
products table, you could use the following query:
SELECT DISTINCT year FROM products ORDER BY 1;
This should give the following result:
You can also use it with multiple columns to get all the distinct column combinations present. For example, to find all distinct years and what product types...