Top 5 By Category

Database
Enthusiast

Top 5 By Category

I need to bring the top 5 items say by sales by Category and Im stuck

I have this

Select
gms,
item_sku_num,
catg,
case when juice = 0 then 0 else lineitemsales/juice end ,
itemqtysold

From
(Select *
From database.table)ttTemp
Qualify Rank () over (partition by catg order by gms desc)=5

1 REPLY
Senior Apprentice

Re: Top 5 By Category

Your QUALIFY returns the 5th highest item, so change it to "<=" instead of "="

Dieter