From the course: MySQL for Data Analysis
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Coding and when to use subqueries and correlated subqueries - MySQL Tutorial
From the course: MySQL for Data Analysis
Coding and when to use subqueries and correlated subqueries
- Using subqueries to refine your data exploration. While table joins discussed previously are a great way to produce reports from multiple tables, some reports can be created more easily with the use of subqueries. For example, if you wanted to calculate say the average or the sum of the values of a column and pass the value to another query, a subquery would work well for solving this problem. We're going to take a look at the couple examples shortly but first let's define a couple terms. So subquery also known as a nested query is a query nested within another query. The subquery typically includes the WHERE clause in the select statement and the WHERE clause will be filtering the data returned to the outer query. Say you wanted to know the customer IDs and payment amounts for customers whose payments are greater than or higher than the average, You could solve this with the use of a subquery. Here the average payment…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.