Turkalp Kucur

Turkalp Kucur

  • NA
  • 50
  • 18.6k

selecting top record in a query.

Nov 13 2012 3:01 PM
Hello there.
I am working on northwind database.
There are nine employees in the database.
Each employee has his&her sales.

My aim is to return the top most of the sales they have done. so there will be nine results.

below script returns all the sales they did, which I could not return the top most sales. 


select e.firstname+' '+e.lastname as [Worker], p.productname as [Top most saled product], r.quantity*r.unitprice as [Price]  from employees as e
inner join orders as o on e.employeeid=o.employeeid
inner join [order details] as r on r.orderid=o.orderid
inner join products as p on p.productid= r.productid
where o.shippeddate is null order by [Price] desc
go


help please.

Answers (6)