Intermediate Joins in SQL - Lesson #4

I respectfully would like to ask if it makes a difference using COUNT(*) versus SUM(quantity). I only inquire about this because what if there was a track purchase that contained a quantity of more than 1. I just like to try to dive as deep as I can to test my understanding. Thanks in advance and I love Dataquest! It has changed my life dramatically!

Although they might appear to perform a similar task, the COUNT() and SUM() functions have very different uses.

COUNT() is used to take a name of a column, and counts the number of non-empty values in that column. COUNT() does not take into account the actual values stored, and only cares if they have a non-empty value. Each row is essentially counted as 1 towards the total count.

On the other hand, SUM() takes a column name, and returns the sum of all values in the column, meaning that it must take into account the actual values stored.

In general, use COUNT() when you want to count how many rows contain a non-empty value for a specified column. Use SUM() when you want to get the total sum of all values in a column.

This StackOverflow answer also provides additional details on the topic.