Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

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

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?

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
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2019 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000