Link to home
Start Free TrialLog in
Avatar of the_b1ackfox
the_b1ackfoxFlag for United States of America

asked on

SQL Calculating The best salesman of the day

Hello Experts,

I have a table that contains information as follows:

SalesID, NumbSales, SalesDate

So: if salesman X sells 23 widgets on thursday, 30 widgets on friday, and 50 on Saturday
if salesman Y sell 14 widgets on Thursday, 33 widgets on friday and 42 widgets on saturday

my table looks like this:
rwid   SalesID   NumbSales   SalesDate

10   | 1         | 23              | '2012-07-06'|
11   | 2         | 14              | '2012-07-06'|
12   | 1         | 30              | '2012-07-07'|
13   | 2         | 33              | '2012-07-07'|
14   | 1         | 50              | '2012-07-08'|
15   | 2         | 42              | '2012-07-08'|


How can I get the salesmans ID who had the max sales for the day?

So I get:

10   | 1         | 23              | '2012-07-06'|
13   | 2         | 33              | '2012-07-07'|
14   | 1         | 50              | '2012-07-08'|

Thank you in advance!

-Fox
ASKER CERTIFIED SOLUTION
Avatar of Lowfatspread
Lowfatspread
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of the_b1ackfox

ASKER

I believe that all of you who answered have answered questions for me in the past.  I thank you all, and will be assigning points shortly after gleaning knowledge from your posts.  I like to comment of what was submitted so that future readers will know what worked well, and what didn't.  Thank you.

Fox
Thank you all for the help with this question.  I actually learned alot from the examples posted.  Sorry for the delay in getting back on this.  I have been away due to family issues