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 |
|
dirwin26
Yak Posting Veteran
81 Posts |
Posted - 2006-06-19 : 11:57:25
|
| I have monthly data in a table and I am trying to grab the max # of sales in each given month by each customer. Here's what my table looks like:Customer//month//salesABC//JAN//5ABC//JAN//20XYZ//JAN//2XYZ//JAN//10So the results of my query will be ABC//JAN//20XYZ//JAN//10What I can't figure out is how to grab a distinct company within each month where the sales =MAX for that one customer. Thanks |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2006-06-19 : 12:17:18
|
| select Customer, Month, Sales = max(Sales)from tblgroup by Customer, Month==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
dirwin26
Yak Posting Veteran
81 Posts |
Posted - 2006-06-19 : 12:28:25
|
| that did the job. Thanks. |
 |
|
|
|
|
|