bhbcom Posted December 16, 2014 Share Posted December 16, 2014 Bonjour. Aidez-moi de composer une requête des produits vendus pour pré-spécifiée dates avec le nombre total des ventes, dans la base de données, s'il vous plait. ID | Produit | Nombre total des ventes Link to comment Share on other sites More sharing options...
Grafics Posted December 16, 2014 Share Posted December 16, 2014 Bonjour, voici un exemple : $sql = 'SELECT od.idproduct, pl.name, SUM(od.`product_quantity`) AS total FROM `'._DB_PREFIX_.'order_detail` od LEFT JOIN `'._DB_PREFIX_.'orders` o ON o.`id_order` = od.`id_order` LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON pl.`id_product` = od.`product_id` WHERE od.`product_id` = '.(int)$id_product.' '.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o').' AND o.`valid` = 1 AND pl.`id_lang` = '.$idlang.' AND (o.`invoice_date` >= \''.$date1.'\') AND (o.`invoice_date` < \''.$date2.'\'))'; A vérifier car de tête et à personnaliser 1 Link to comment Share on other sites More sharing options...
bhbcom Posted December 17, 2014 Author Share Posted December 17, 2014 (edited) Bonjour, voici un exemple : $sql = 'SELECT od.idproduct, pl.name, SUM(od.`product_quantity`) AS total FROM `'._DB_PREFIX_.'order_detail` od LEFT JOIN `'._DB_PREFIX_.'orders` o ON o.`id_order` = od.`id_order` LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON pl.`id_product` = od.`product_id` WHERE od.`product_id` = '.(int)$id_product.' '.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o').' AND o.`valid` = 1 AND pl.`id_lang` = '.$idlang.' AND (o.`invoice_date` >= \''.$date1.'\') AND (o.`invoice_date` < \''.$date2.'\'))'; A vérifier car de tête et à personnaliser Merci! Çà marche bien. SELECT product_id, product_name, SUM(product_quantity) AS total FROM kn_order_detail LEFT JOIN kn_orders ON kn_orders.id_order = kn_order_detail.id_order WHERE kn_orders.valid = 1 AND (kn_orders.invoice_date >= '2014-01-01') AND (kn_orders.invoice_date < '2015-01-01') GROUP BY product_id; Maintenant j'ai besoin de trouver le nombre total des ventes pour chaque couleur. Noir | Total ventes Blanc | Total ventes Rouge | Total ventes Je sais que les tables pour déclinaison c'est kn_product_attribute et kn_product_attribute_combination mais je ne peux pas trouver les couleur la-bas.. Edited December 17, 2014 by bhbcom (see edit history) Link to comment Share on other sites More sharing options...
Grafics Posted December 17, 2014 Share Posted December 17, 2014 Il faut associer la table avec un left joint avec la attribute_lang pour avoir les noms. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now