The short answer
OVER() defines the window over which the calculation happens.
SUM(salary) OVER ()calculates across all rows.
SUM(salary) OVER (
PARTITION BY department
)calculates separately for each department.
GROUP BY
Many rows → fewer rows
PARTITION BY
Many rows → still many rows
It just splits the rows into groups for the window calculation. You still keep every row.