bmacuer's Profile User Rating: -----

Reputation: 0 Apprentice
Group:
New Members
Active Posts:
2 (0 per day)
Joined:
27-July 12
Profile Views:
124
Last Active:
User is offline Aug 01 2012 11:10 PM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   bmacuer has not set their status

Posts I've Made

  1. In Topic: mySQL query problem

    Posted 29 Jul 2012

    Thanks for the help it was very useful I had to add a WHERE CLAUSE though because it was overloading the server once I wanted to create the report, it might be because the are many items sold and also products, so this was the code that worked for me.

    SELECT 
      product.product_id, 
      product.product_brand_id, 
      product.product_model_id, 
      product.product_subcategory_id, 
      product.product_retail_price, 
      product.product_wholesale_price, 
      SUM(product_sold.product_quantity) AS product_quantity_sold, 
      SUM(product_sold.product_total_price) AS total_price_sold 
    FROM product
    LEFT JOIN product_sold 
      ON product.product_id = product_sold.product_id 
      AND product.product_brand_id = '$brand_id' 
      AND product.product_model_id = '$model_id' 
      AND product.product_subcategory_id = '$subcategory_id'
    LEFT JOIN sales 
      ON sales.sales_id = product_sold.product_sales_id 
      AND product_sold.product_warehouse_id = '$warehouse_id' 
      AND sales.sales_approved = '1' 
      AND sales.sales_approved_time > '$start_timestamp' 
      AND sales.sales_approved_time < '$end_timestamp'
    WHERE 
      product.product_brand_id = '$brand_id' 
      AND product.product_model_id = '$model_id' 
      AND product.product_subcategory_id = '$subcategory_id' 
    GROUP BY 
      product.product_id 
    ORDER BY 
      SUM(product_sold.product_quantity) DESC
    
    

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private

Friends

bmacuer hasn't added any friends yet.

Comments

bmacuer has no profile comments yet. Why not say hello?