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.
Author |
Topic |
datakeyword
Starting Member
10 Posts |
Posted - 2013-07-25 : 23:25:24
|
Based on the policy data details, how to find out the salesman who sold the most or the least insurance products during a certain period?SQL: SELECT salesMan FROM (SELECT salesMan, row_number() OVER (ORDER BY isrCount DESC) descOrder, row_number() OVER (ORDER BY isrCount ASC) ascOrder FROM (SELECT salesMan, COUNT(*) isrCount FROM insurance where salesDate>= ? and salesDate<=? GROUP BY salesMan ) ) WHERE descOrder=1 OR ascOrder=1 ORDER BY descOrderWith esProc:How about Java or Etl? Hope for your better solution.Jim KingBI technology consultant for Raqsoft10 + years of experience on BI/OLAP application, statistical computing and analyticsEmail: Contact@raqsoft.comWebsite: www.raqsoft.comBlog: datakeyword.blogspot.com/ |
|
|
|
|