Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Complex 80 20 Query

Author  Topic 

csjain1978
Starting Member

3 Posts

Posted - 2013-05-09 : 03:08:52

I am new to writing sql queries and have a particularly complex query that I wish to write.

It is essentially applying the Pareto Principle (80/20 Principle) to a set of sales data and update a column in each row of a table based on the business logic.

The business logic is
If a customer is among to 80% sales of a particular year then it is called High Volume else Low Volume
Similarly for a product.

It has been explained clearly with sample data in the excel sheet which you can find here :

https://www.dropbox.com/s/7r2s5z0h1zcfnme/80%2020%20Sales%20query%20SQL.xlsx



Will appreciate your help.

Regards

Chandra

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-05-09 : 04:46:14
Sounds like you need to use PERCENTILE_DISC() function to get the 80 % part and then use it to retrieve customers that are part of it

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

csjain1978
Starting Member

3 Posts

Posted - 2013-05-09 : 05:45:42
Visakh

Would appreciate if you could elaborate with an example.

Chandra
Go to Top of Page

MIK_2008
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2013-05-09 : 07:58:27
you may find it here... http://msdn.microsoft.com/en-us/library/hh231327.aspx

Cheers
MIK
Go to Top of Page

csjain1978
Starting Member

3 Posts

Posted - 2013-05-09 : 10:02:11
I saw that MIK_2008.
Was not able to make it work and hence asked Visakh to elaborate

Chandra
Go to Top of Page
   

- Advertisement -