| Author |
Topic |
|
sambrown180
Starting Member
38 Posts |
Posted - 2008-12-09 : 11:33:51
|
| i want to make a wishlist query with the most popular product at the top of the results. The information shall be taken from one tablein it will be product id and product priceplease can you tell me what coding do i need to write |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-12-09 : 11:35:25
|
| most popular on what basis? based on price? |
 |
|
|
sambrown180
Starting Member
38 Posts |
Posted - 2008-12-09 : 11:38:44
|
| O on how many people added it to their wshlist. so i take it List_ID is also required |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-12-09 : 11:41:39
|
| [code]SELECT productidFROM YourTableGROUP BY productidORDER BY COUNT(List_ID) DESC[/code] |
 |
|
|
GilaMonster
Master Smack Fu Yak Hacker
4507 Posts |
Posted - 2008-12-09 : 11:43:06
|
| If visakh's query doesn't work, post the schema of the tables involved. Without that, all we can do is guess.--Gail ShawSQL Server MVP |
 |
|
|
sambrown180
Starting Member
38 Posts |
Posted - 2008-12-09 : 12:09:11
|
| In my wishlist I haveList_ID as my primary keyCustomer_ID as a foreign keyProduct_ID as a foreign keyProduct_PriceI tried that query above and it doesnt work any suggestions on any other codes? |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
sambrown180
Starting Member
38 Posts |
Posted - 2008-12-09 : 12:19:19
|
| I done this codeSELECT Product_ID FROM WishlistGROUP BY Product_IDORDER BY COUNT(List_ID) DESCbut it doesnt seem to be working and it doesnt include product price. Where would I put product price |
 |
|
|
raky
Aged Yak Warrior
767 Posts |
Posted - 2008-12-09 : 12:22:47
|
| SELECT Product_ID ,Product_PriceFROM WishlistGROUP BY Product_ID,Product_PriceORDER BY COUNT(List_ID) DESCslight modification to vishak's solution.... |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-12-09 : 12:24:52
|
quote: Originally posted by sambrown180 I done this codeSELECT Product_ID FROM WishlistGROUP BY Product_IDORDER BY COUNT(List_ID) DESCbut it doesnt seem to be working and it doesnt include product price. Where would I put product price
did you see link i posted. whats is stopping you from posting information asked? cant you understand we cannot see your system nor can we read your mind? how will we know what all you want as output?SELECT w.*FROM wishlist wINNER JOIN (SELECT Product_ID,COUNT(List_ID) AS Subscription FROM WishlistGROUP BY Product_ID)tON t.Product_ID=w.Product_IDORDER BY t.Subscription DESC |
 |
|
|
sambrown180
Starting Member
38 Posts |
Posted - 2008-12-09 : 12:46:58
|
| thanks for all the help i have sorted it now |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-12-09 : 12:48:56
|
| cheersAt least in future provide relevant info for helping us to help you fast. |
 |
|
|
|