21.1. SQL Part 3 - Joins

Read the following articles, and watch the videos:

21.1.2. HAVING clause

The HAVING clause is very similar to a WHERE clause in that it is used to filter result sets. However, we cannot use the WHERE clause with aggregate functions. Instead, we have to use the HAVING clause. If you want to use an aggregate function with a join, then you need to make use of this new clause. The HAVING clause is often used with GROUP BY.

  1. SQL HAVING.

  2. Intermediate SQL Tutorial | Having Clause.

21.1.3. Check Your Understanding

Question

What does an INNER JOIN do?

  1. Returns results with matching rows in both tables

  2. Returns results with all the rows from the left table with null values for unmatched rows from the right table

  3. Returns results with all the rows from the right table with null values for unmatched rows from the left table

  4. Returns results from all the rows from both tables with null values filled in for all unmatched rows.

Question

What does a FULL JOIN or OUTER JOIN do?

  1. Returns results with matching rows in both tables

  2. Returns results with all the rows from the left table with null values for unmatched rows from the right table

  3. Returns results with all the rows from the right table with null values for unmatched rows from the left table

  4. Returns results from all the rows from both tables with null values filled in for all unmatched rows

Question

In your own words what is the difference between a RIGHT JOIN and a LEFT JOIN?

Question

In what order do the following clauses go when writing a query?

  1. SELECT, WHERE, HAVING, GROUP BY

  2. SELECT, HAVING, WHERE, GROUP BY

  3. SELECT, WHERE, GROUP BY, HAVING

  4. SELECT, HAVING, GROUP BY, WHERE

Question

Can you use aggregates with the HAVING Clause?

  1. True

  2. False

Question

Can you use aggregates with the WHERE clause?

  1. True

  2. False

Question

In your own words, what is the difference between the WHERE clause and the HAVING clause?