r/SQL • • Oct 20 '26

MySQL COUNT() vs COUNT() OVER()

Post image

I've found this query as a solution to the famous Pizza Runner case study, and I am stuck at figuring out what COUNT() returns, compared to COUNT() OVER().

I know OVER() does the count (or whatever aggregation) over the entire dataset, but idk I'm just not getting the percentage part of this query.

Help :)

25 Upvotes

17 comments sorted by

View all comments

6

u/jacquesrk oracle Oct 21 '26

To find the volume of pizzas ordered, wouldn't you need to know the diameter and thickness of the pizzas?

3

u/RandumbNumber Oct 21 '26

Not sure if you’re kidding or not, but this is exactly what I thought, until I read the comments and released it’s not volume but percentage. So either really poorly phrased question, or a wrong answer.
I’ve never seen volume interpreted the way it is here.

2

u/Plus_Kiwi_2592 Oct 21 '26

The phrasing bothered me too. But if you see the schema then you'll just know volume isn't the size.

I rarely hear the word volume being used in certain corporate spaces, but there are a few that make use of it that way.

Just goes to show that the most important part of analytics is the business sense, not the syntax. If the business question is wrong, then the syntax will give wrong insight.