Oct 10, 2006 #1 A11AR Programmer Oct 10, 2006 1 US Hi all, Can any one give me a breif idea that how to calculate top 20 % of the values. I have stores which has got sales per year and i would like to get only top 20 % of the stores. I would greatly apreciate the help Thanks a lot
Hi all, Can any one give me a breif idea that how to calculate top 20 % of the values. I have stores which has got sales per year and i would like to get only top 20 % of the stores. I would greatly apreciate the help Thanks a lot
Oct 12, 2006 #2 GerardMcL Technical User Aug 5, 2004 212 IE To get the TOP 20% of rows according to your WHERE clause it is SELECT TOP 20 PERCENT stores Just new to TD but I think this should give you what your after Upvote 0 Downvote
To get the TOP 20% of rows according to your WHERE clause it is SELECT TOP 20 PERCENT stores Just new to TD but I think this should give you what your after
Oct 14, 2006 2 #3 dnoeth Instructor Oct 16, 2002 545 DE select * from tab qualify percent_rank() over (order by sales desc) <= 0.2 Easy to enhance with PARTITION BY, e.g. percent_rank() over (order by sales desc partition by year) <= 0.2 to get top 20% per year... Dieter Upvote 0 Downvote
select * from tab qualify percent_rank() over (order by sales desc) <= 0.2 Easy to enhance with PARTITION BY, e.g. percent_rank() over (order by sales desc partition by year) <= 0.2 to get top 20% per year... Dieter