I am trying to get the highest spend and show the vendor that has the highest spend in the category . Here is what i have:
Vendor Category Spend
3M cat1 200
XX cat6 150
Bos cat1 700
JJ cat0 500
KLM cat0 100
XX cat0 400
This is the desired results:
Vendor Category Spend
XX cat6 150
Bos cat1 700
JJ cat0 500
i am not getting the right results
select vendor, category, sum(spend) ,row_number() over(partition by vendor order by spend desc) as roworder
from myTable
group by vendor, category