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

0

u/Little_Kitty Oct 21 '26

This looks like hackerrank or similar. Real work is nothing at all like this and if that's what you're using to practice you'll fall short when you get to interview anywhere decent.

1

u/EbbyRed Oct 21 '26

I use window functions and aggregates every day in my job. 

0

u/Plus_Kiwi_2592 Oct 21 '26

This is someone's answers to the 8 Week SQL Challenge. Real-life business problems

-1

u/my_password_is______ Oct 21 '26

no, in real life you'd just pull the raw numbers into excel and make a pivot table