Java Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingJava Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 21st, 2013, 10:16 PM
datalover datalover is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2013
Posts: 2 datalover User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 13 m 17 sec
Reputation Power: 0
How to calculate the sets of a set, ordered set, generic set?

How to represent the sets of a set, ordered set, generic set? Many operations on sets are hard to implement through SQL. Moreover, the computation is not limited on database, such as the data from Excel and even there is no database in the application environment. In this case, how do you deal with it?

Letís check it out with this example: a sales department needs to make statistics on the outstanding salesmen who account for half of the total sales based on their sales records.

With esProc, it can dealt with as follows,

A B
1=$select*from salesOrder
2=A1.group(name;name,~.sum(sales):salesSum)
3=A2.sort@0(salesSum:-1) =A2.sum(salesSum)/2
4=A3.derive(A3.(salesSum).cumulate()(#):addup)
5=A4.select(addup<=B3||(addup>B3&&addup[-1]<B3))

With R, it can be dealt with like:
  01 library(RODBC)
  02 odbcDataSources()
  03 conn<-odbcConnect("sqlsvr")
  04 originalData<-sqlQuery(conn,'select * from salesOrder')
  05 odbcClose(conn)
  06 nameSum<-aggregate(originalData$sales,list(originalData$nam e),sum)
  07 names(nameSum)<-c('name','salesSum')
  08 orderData<-nameSum[rev(order(nameSum$salesSum)),]
  09 halfSum<-sum(orderData$salesSum)/2
  10 orderData$addup<-cumsum(orderData$salesSum)
  11 subset(orderData,addup<=halfSum | (addup>halfSum & c( 0, addup[- length (addup)]) <halfSum))

Do you have any other ways?

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJava Development > How to calculate the sets of a set, ordered set, generic set?


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.

© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap