How many accounts do we have in music.Account?
SELECT COUNT(*) FROM music.Account;
How many countries do our users come from?
SELECT COUNT(DISTINCT Country) FROM music.Users;
What’s the total listening time of all the songs in our database?
SELECT SUM(duration) FROM music.Song;
Recall the distinction between
SELECT * and
In the former, we return values from every column in the table. In the latter, we map 1 to every tuple in the result set.
Furthermore, when we map 1 and reduce using either
COUNT(1), we find the two expressions are equivalent.
COUNT(*) will return equivalent results - i.e. the number of tuples in each projection.