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
 Development Tools
 Other Development Tools
 Massive data computing in Java with SQL and esProc

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 descOrder

With esProc:


How about Java or Etl? Hope for your better solution.

Jim King
BI technology consultant for Raqsoft
10 + years of experience on BI/OLAP application, statistical computing and analytics
Email: Contact@raqsoft.com
Website: www.raqsoft.com
Blog: datakeyword.blogspot.com/
   

- Advertisement -