Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 Database Design and Application Architecture
 finding top quantity sold of the books

Author  Topic 

capriman
Starting Member

4 Posts

Posted - 2011-12-10 : 06:48:15
SELECT b.ISBN,sum(o.quantity) as TOTALQTYSold,avg((RETAIL-COST)/COST*100) AS PERcentPROFIT
FROM BOOKS b, orderitems o
WHERE b.isbn=o.isbn
group by b.isbn
order by TOTALqtysold desc;

here is my sql but need to only show the Top 5 Isbn and the rest of the columns for the top 5 quantity sold books????

thanks,
capriman

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-12-10 : 07:09:49
[code]
SELECT TOP 5 b.ISBN,sum(o.quantity) as TOTALQTYSold,avg((RETAIL-COST)/COST*100) AS PERcentPROFIT
FROM BOOKS b, orderitems o
WHERE b.isbn=o.isbn
group by b.isbn
order by TOTALqtysold desc;
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

capriman
Starting Member

4 Posts

Posted - 2011-12-10 : 07:37:28
getting an error on line 2 for some reason with the suggested code??
I am using SQL developer to do this??

thanks
Go to Top of Page
   

- Advertisement -