From the course: SQL Essential Training

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

DISTINCT clause subquery

DISTINCT clause subquery - SQL Tutorial

From the course: SQL Essential Training

DISTINCT clause subquery

- [Instructor] As we've seen from other examples that we've done so far in this chapter, sub queries are very helpful, for scenarios where you want to view or compare a query by a condition that requires its own query to calculate. As we learned prior, there is usually one unique field in every table, known as the primary key, which contains a unique number for every record. However, the other fields in a table may contain redundant information. To work better with redundant information, it's often convenient to filter this data, so that it only displays unique or distinct values. Now this is where the distinct keyword comes in. To demonstrate sub queries and the distinct keyword, let's take a look at the invoice line table. The invoice line table shows us which individual WSDA music tracks were purchased on each invoice. Now, let's take a look at this query in front of us here, which is selecting just the track ids from…

Contents