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.
| Author |
Topic |
|
frank88
Starting Member
4 Posts |
Posted - 2008-12-03 : 08:42:19
|
| Hey, I have got three tables Order_Line (shows the different orders that have been made), product (shows the different products and details) and wishlist (shows which products are wanted by customers).I want to write a query that will show me what the most popular product is that appears in the orders table and the wish list table.Or alternatively a count that will show how many of each product have been bought and are wanted.Can anyone help. |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2008-12-03 : 08:55:33
|
| do this for both tables:select top 1 productId, count(*) as cntfrom yourTable group by productIdorder by count(*) desc___________________________________________________________________________Causing trouble since 1980Blog: http://weblogs.sqlteam.com/mladenpSpeed up SSMS development: www.ssmstoolspack.com <- version 1.1 out! |
 |
|
|
frank88
Starting Member
4 Posts |
Posted - 2008-12-03 : 09:04:16
|
| Thanks for the help |
 |
|
|
|
|
|