Board logo

subject: Top 3 Salespersons By Monthly Sales: R Language V.s Esproc [print this page]


Top 3 Salespersons by Monthly Sales: R Language v.s esProc

Both R language and esProc have the outstanding ability to perform the step by step computations. And they are great tools for statistical computing. However, in the particulars they differ from each other. To demonstrate the difference, a case for statistical computing is designed as follows:

A company' s Sales department wants to select out the outstanding salespersons through statistics, that is, the salespersons whose sales amounts are always among the top 3 in each month from the January this year to the previous year. The data is mainly from the order table of database: salesOrder, and the main fields include the ID of order: ordered, name of salesperson: name, sales amount: sales, and date of order: salesDate.

The solution is like this substantially:

Compute the beginning dates of this year and this month, and filter the data by date.

Group by month and salesperson, and compute the sales amount of each salesperson in each month.

Group by month, and compute the rankings of sales amount in each group.

Filter out the top 3 salespersons from each group.

Compute the set of intersections of each group, that is, salespersons always among the top 3 in each month.

The solution of R language is shown as below:

01 library(RODBC)

02 odbcDataSources()

03 conn

by: Datakeyword




welcome to loan (http://www.yloan.com/) Powered by Discuz! 5.5.0