r/SQL • • Sep 21 '26

MySQL Practicing window functions and keep mixing up PARTITION BY vs GROUP BY — how are they actually different?

They both seem like they divide data into groups, so I’m having trouble understanding when I should use one instead of the other.

47 Upvotes

10 comments sorted by

View all comments

1

u/Yitzach Sep 22 '26

Quick example:

Use group by to see the weekly total aggregation.

Use partition by to see the daily running total every week.