Thanks for the help ceco,
I am sorry, but I posted to so many forums that I forgot to put my final answer on this forum. The conclusion that I came to (with a lot of help from a couple of forums) is this final query. And it works great and seems to execute very quickly. What I forgot...
Here is my problem and it appears that it may only be a problem with PostgreSQL:
I am trying to order the products on my online store showing the products that have been sold the most amount of times within the last week on the top.
There are a lot of products that may not have been sold...
Well, i think I finally figured it out. Here it is:
SELECT orders_prods.prod_id, SUM(orders_prods.quantity) AS quantitySold, products.thumbnail, products.main_image, products.prod_price, products.prod_id, products.prod_name FROM products INNER JOIN product_categories ON products.prod_id =...
I know it's: "AND orders_prods.order_date > '$dateSevenDaysAgo' " thats limiting the whole selection to only the products it finds sold within the last week, but I need it to limit this query to order by sales within the last week.
I received some help on another forum and I almost have this query working now. The only problem I am having is that it doesn't pull every product out of the products table because there is not always a prod_id in the orders_prods table to match the prod_id in the products table (especially...
I am trying to order products in our online store based on sales. For instance, if one product sold 15 times last week, it would be shown above a product that sold 8 times last week. This is a typical online store with a database consisting of a products table, orders table (containing...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.