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
 New to SQL Server Programming
 the details of the product that has been sold the

Author  Topic 

rajdey1
Starting Member

10 Posts

Posted - 2009-04-25 : 13:48:45
hi pls help me to write sql querry for the following

the details of the product that has been sold the most

Table order_details
(order_no,order_date,product_no,customer_id,quantity)

Table Product
(product_no,Product_name,Price,cures,product_type)

nr
SQLTeam MVY

12543 Posts

Posted - 2009-04-25 : 16:06:26
select p.*
from Product p
join
(select top 1 product_no, s=sum(quantity)
from order_detils
group by product_no
order by s) s
on p.product_no = s.product_no

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

rajdey1
Starting Member

10 Posts

Posted - 2009-04-25 : 23:57:39
hi the sql statement you have given doesnt work
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-04-26 : 03:32:54
Please explain your definition of "doesn't work".



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

rajdey1
Starting Member

10 Posts

Posted - 2009-04-26 : 07:53:26
on runing the querry gives a message syntax error in from clause
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-04-26 : 08:03:16
Try exchange

order by s

with

order by sum(quantity) desc




E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

rajdey1
Starting Member

10 Posts

Posted - 2009-04-26 : 08:26:38
tried but still doesnot work actually problem with from clause before join keyword
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2009-04-26 : 08:44:27
Rajdey-

Do not spam SQL Team with your homework assignments:

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=124564
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=124563
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=124561
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=124560
Go to Top of Page

rajdey1
Starting Member

10 Posts

Posted - 2009-04-26 : 16:11:49
not spamming i working hard to solve the problem jus begging help from the members of the forum
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-04-27 : 09:45:14
since you're "working hard to solve the problem" please provide what you have tried so far for each of your posts. That will help us gauge what your level is as well as prove to us that you are in fact putting in some effort.

Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -