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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2001-02-09 : 13:58:33
|
Peter writes " OK, here is one that has me stumped. I have a SQL Server 7 sales database. The structure goes something like:
invoice header -> invoice detail -> product structure. |-> customer |-> customer type
The invoice header record contains the date denormalized to year and month.
My client is looking for a query that returns the top 10 sales by product / customer type for every month in a year.
Obviously this is a histogramic type select, and I can join my query with a view of every month in a year. Using a sum(invoice_detail.quantity) function, I can get the values for the bins.
How do I return the top 10 per month/product? Any way I use the 10 n function, I only get 10 records in total back.
Pete" |
|
|
|
|
|