GROUP BY vs ORDER BY/ HAVING vs WHERE in SQL

John Wolfe
2 min readJun 4, 2018

Lately I’ve been reviewing SQL to advance my database knowledge.

One of the peculiar aspects of SQL I consistently found myself looking up was the difference between GROUP BY and ORDER BY.

Essentially, GROUP BY is an SQL query that is usually accompanied by an aggregate function. For instance, let’s look at the following SQL query:

SELECT Count(*), genre FROM books GROUP BY genre

In the above SQL Query, the count of the returning rows occur in relation to genre

--

--

John Wolfe

Software developer Tata Consultancy Services. React, Rails, and Java. Former content editor for @Quora and @inversedotcom. I live in Chicago, Illinois.