There's 3 common errors that students run into when working with SQL:
- ERROR: not a single-group function
- ERROR: ambiguous column name
- ERROR: syntax error
Let's go one-by-one and see how we can correct each!
ERROR: not a single-group function
Simply put, you forgot your GROUP BY statement.
In GROUP BY, we discussed the golden rule of GROUP BY statements:
"Whenever you have field(s) and aggregate function(s) in your SELECT statement, you must include all field(s) in your GROUP BY statement."
So, if you get this error, chances are you didn't write a GROUP BY statement with all the field(s) of your SELECT statement.
For example, if I had the following SQL statement...