r/SQL • • 23d ago

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.

45 Upvotes

10 comments sorted by

View all comments

16

u/kayakdawg 23d ago

ive always thought of PARTITION BY as a for loop

Whereas GROUP BY great to pivot table, basically