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 |
|
wasimkham
Starting Member
2 Posts |
Posted - 2009-10-17 : 08:06:50
|
| Hi, I have a table full of purchased items and i want to be able to select the top 10 most purchased products for a given user. I want to return the ID of those along with how many instances of that ID exists.I'm using the following SQL code SELECT TOP (10) beat_id, Count(*) FROM jos_mfs_items WHERE producer = 100 GROUP BY beat_id ORDER BY COUNT(*) DESCBut it doesn't return anything, does anyone have any clues why?Thanks |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-10-17 : 08:11:11
|
Maybe there is no producer=100 No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
wasimkham
Starting Member
2 Posts |
Posted - 2009-10-17 : 10:28:53
|
quote: Originally posted by webfred Maybe there is no producer=100 No, you're never too old to Yak'n'Roll if you're too young to die.
There is definitely a producer = 100 |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-10-17 : 10:41:41
|
This test is working fine and there nothing different to yours but the data...select top (2) type, count(*)from sys.objectswhere is_ms_shipped=1group by typeorder by count(*) desc No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|