Skip to content
Advertisement

What am I getting wrong in this SQL query?

Write a query that retrieves only a ranked list of the most prolific days in October 2020, prolific measured in number of posts per day. Your query should return those days in a single-column table (column name post_day) in the format YYYY-MM-DD.

This is my table:

This is my query:

The problem is that I’m only getting one result, not a descending order of dates:

Advertisement

Answer

add GROUP BY CAST(posted_at AS DATE) after WHERE clause and before HAVING clause. Also, check your WHERE clause. You are likely missing the last couple of days.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement