JElster
asked on
TOP N BY GROUP
Hi.. I have table of sales reps and products and sales.. I need the top 10 sales persons by product
name product sales
john tv 100
mary phone 50
john phone 10
bob radio 5
mary clock 59
using sql 2005 !
name product sales
john tv 100
mary phone 50
john phone 10
bob radio 5
mary clock 59
using sql 2005 !
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
try:
modified...
Select Top 10 name, product, SumSale
From
(
Select name, product, Sum(sales) As SumSale
From MyTable
Group By product, name
) As D ( name, product, SumSale)
Order By product, SumSale Desc, name
modified...
ASKER
The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions
Any ideas?
Any ideas?
The ORDER BY clause is invalid in views, inline functions, derived tables, and common table expressions unless top(x) and offset fetch is utilized.
ASKER
'dense_rank' is not a recognized function name.
Any way to do in SQL2000?