Factbook project in R path

In the solutions for the Factbook project in the R path, one line is not running:

Investigating outlier values

q3 = “SELECT * FROM facts WHERE (population == MAX(population))”
result3 = dbGetQuery(conn, q3)

Error message: Error: misuse of aggregate function MAX()

Please advise.

When using an aggregate function (sum / count / … ), you also have to make use of the GROUP BY clause. Explore in this direction. If you’ll get stuck again, please, let us know, we’ll be happy to help further!

1 Like

q3 <- “SELECT * FROM facts WHERE population == (SELECT MIN(population) FROM facts)”
It is the same problem we found in the first two steps of the subqueries mission.