MySQL Forums
Forum List  »  InnoDB

Top 3 products from each category. Possible?
Posted by: a g
Date: March 18, 2008 07:34AM

I have been puzzled with this for some time now without being able to find any solution. The database stores sales/discounts from different stores. The goal is to get top 3 deals created today (product_date) with biggest discounts (product_sale field stores discount amount in %; 50%, 60%) from each category.


Tables

products
--------
product_id int(11)
product_title varchar(255)
product_sale decimal(15,2)
product_date int(11)
PRIMARY ID: product_id

categories
----------
cat_id int(11)
name varchar(100)
PRIMARY ID: cat_id

prod_cat
-------
rel_id int(11)
product_id int(11)
cat_id int(11)
PRIMARY ID: cat_id
INDEX: iid(product_id, cat_id)

Thank you.



Edited 2 time(s). Last edit at 03/18/2008 07:41AM by a g.

Options: ReplyQuote


Subject
Views
Written By
Posted
Top 3 products from each category. Possible?
2712
a g
March 18, 2008 07:34AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.