SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Development Tools
 Other Development Tools
 Massive data computing in Java with SQL and esProc
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

datakeyword
Starting Member

10 Posts

Posted - 07/25/2013 :  23:25:24  Show Profile  Reply with Quote
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/
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000