Hello, I have a question about how to construct a specific query (using the TOP keyword?)
I'll reduce the problem to it's essence:
given is a table of sales records containing
sales_record_id, agent_id, item_id, solditems
There are no restrictions on how many times an agent or an item can occur, but every combination agent_id-item_id occurs exactly once.
For every agent I want his/her top 5 (or less) most sold items as a result. This has to be available in a view, so no variables or cursors allowed.
Version is SQL Server 2005.
Thanks for helping me out.
Brick.
I'll reduce the problem to it's essence:
given is a table of sales records containing
sales_record_id, agent_id, item_id, solditems
There are no restrictions on how many times an agent or an item can occur, but every combination agent_id-item_id occurs exactly once.
For every agent I want his/her top 5 (or less) most sold items as a result. This has to be available in a view, so no variables or cursors allowed.
Version is SQL Server 2005.
Thanks for helping me out.
Brick.