The Difference Between Two SQL Statements

Hi, I’m doing the Data Scientist: Machine Learning course, and in one of the projects in the Learn SQL section ( Analyze Hacker News Trends ), it tells me that I need to pinpoint the users who have accumulated alot of points across their stories. and it tells me to use the GROUP BY and HAVING
clause in the statement. This is the correct statement:

SELECT user, SUM(score) 
FROM hacker_news 
GROUP BY user 
HAVING SUM(score) > 200;

But I first tried to use this statement:

SELECT user, score 
FROM hacker_news 
WHERE score > 200;

I was first unsure if this was correct so I decided to compare the two statements and they both had the same result. The only difference was the order of the results. So is there any real difference? Thanks!


WHERE filters rows.
HAVING filters groups.

If unsure, consult the documentation.

1 Like

I mean I got same results from both but ok thanks for the information!