Avatar of ottenm
ottenm

asked on 

ht get average sales per sales rep? (MS SQL 2000)

The query below returns sales statistics from the 'order_entry' table.  With one row for each sales rep, I get the sum of sales, the count of the number of sales, and the average amount of each sale.  I have removed some additional where clauses to simplify this question.  

What I need to return instead is (a single row): the sum of sales, the count of the number of sales reps, and the average amount of sales per rep.

Thanks for any help-

select rep_name, sum(totalprice) as total, count(*) as num, sum(totalprice)/count(*) as average
from order_entry oe inner join employees e
on oe.sales_rep_emp_number = e.employee_number
-- where clauses that filter by date and by employee criteria
group by oe.sales_rep_emp_number, e.rep_name
Microsoft SQL Server

Avatar of undefined
Last Comment
ottenm

8/22/2022 - Mon