I have a database table with three columns.
WeekNumber, ProductName,SalesCount
Examples of data are given in the table below. I want to get the top 10 players (%) for week 26 for the previous week, i.e. Week 25. The only condition is that in both weeks the product must have more than 0.
In the sample data, B, C, D are common products, and C has the highest gain%.
Likewise, I will need the top 10 losers.
What I have tried so far is to make an inner join and get common products between two weeks. However, I cannot get the logic of the best winners.

The output should look like
Product PercentGain
C 400%
D 12.5%
B 10%
source
share