Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Providing detailed information and counting objects
Calculating metrics for multiple business objects
Understanding the difference between various count metrics
Summary
14. Summary

Instruction

It's time to wrap things up for this part. First, let's review what we learned:

  1. SQL reports often require joining a lot of tables.
  2. Every column listed in the SELECT statement that's NOT used with an aggregate function must appear in the GROUP BY clause.
  3. Not every column from the GROUP BY clause must appear in the SELECT clause.
  4. Watch out when using COUNT().
  5. Type of count What is counted
    COUNT(*) all rows
    COUNT(ColumnName) rows with non-NULL values in ColumnName
    COUNT(DISTINCT ColumnName) only the unique values in ColumnName
  6. Avoid using LEFT JOINs with COUNT(*). Use COUNT(ColumnName) instead.

How about a short quiz before we start the next part?

Exercise

Find the total number of products supplied by each supplier. Show the following columns: SupplierID, CompanyName, and ProductsSuppliedCount (the number of products supplied by that company).

Stuck? Here's a hint!

Join the Products and Suppliers tables. Group by two columns: SupplierID and CompanyName.