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

3

u/SP3NGL3R Oct 21 '26

when dealing with this stuff, break the bits into their own columns so you can visually confirm what is happening. If you do this you'll see pretty quickly where the fault is.

1

u/Plus_Kiwi_2592 Oct 21 '26

Thanks. Will do :)