0

Hello,

Question: List the top 25% of employees in terms of sales. Your list should include employee number, last name, first name, total number of orders, total sales.

Here is what I have so far (not sure if my inner joins or even the query is totally correct):

select e.employee_no, e.fname, e.lname, count(o.employee_no) as order_count, sum(ol.qty * p.unit_price) as totalsales
from oes2.employee e
inner join oes2.orders o on e.employee_no = o.employee_no
inner join oes2.orderline ol on o.order_no = ol.order_no
inner join oes2.product p on ol.product_no = p.product_no
group by e.employee_no, e.fname, e.lname
order by sum(ol.qty * p.unit_price) desc


So yes. I just need to list the top 25% of the totalsales. How can I do that?

Thanks,

Mick

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by debasisdas
0

Try this sample SQL.

select * from (select * from aer order by aer_id desc)
where rownum <= (select count(*)/4 from aer)
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.