Only this week, get the SQL Complete Track of 9 courses in a special prize of $330 $89!
Nested CTEs
6. Simple nested CTEs – exercise


Excellent! Let's do one more exercise of this kind.


Count the maximal AmountEarned on a given day for each city. Then, calculate the average maximal amount across all cities on a given day. Finally, count the number of days on which that average maximum amount exceeded $1700. Name this column BigAvgNumber.

Stuck? Here's a hint!

Use MAX(AmountEarned) in the first CTE, then use AVG on that aggregate result. In the outer query, use COUNT.