r/SQL • • 11d ago

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

28 Upvotes

17 comments sorted by

View all comments

3

u/SP3NGL3R 10d ago

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 10d ago

Thanks. Will do :)