I've been using GROUP BY for aggregations for a while, but I still find window functions a little confusing when deciding which approach makes more sense.
For example, if I need the highest salary in each department, I could use aggregation or a window function like RANK() or ROW_NUMBER(), depending on what I need in the result.
How do you usually decide between these approaches? Are there situations where window functions are clearly the better choice?
I'd appreciate some practical examples that helped you understand when to use one over the other.