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 :)

29 Upvotes

17 comments sorted by

View all comments

2

u/dontich Oct 21 '26

It's just taking the count / the sum of the rest of the rows

So row 1 is 1 / (1+3+3+1+3+3) = 1/14 or 7.14%