Database · Medium
Find the best-selling product in each category by revenue.
DatabaseSQL QueriesSeniorWindow Functions
Answer preview
This is top-N-per-group: aggregate revenue per product, then rank within each category with a window function and keep rank 1.…