bonjour tout le monde , je suis entrain de preparer une requette pour extraire le details des ventes realiser mais j'ai des erreur, svp quel qu'un peux m'aider pour couriger les erreurs
SELECT DATE_FORMAT(o.date_add, '%Y-%m-%d') date_cmde,
o.id_order AS 'Num commande',
p.name AS 'Produit',
r.quantity AS 'Quantite',
o.total_products AS 'Prix produit',
o.total_shipping AS 'Transport',
o.total_paid AS 'Total commande',
a1.company AS 'Raison sociale',
c1.id_gender AS 'Civilite',
a1.lastname AS 'Nom',
a1.firstname AS 'Prenom',
a1.address1 AS 'Addresse de facturation',
a1.address2 AS 'Addresse de facturation 2',
a1.postcode AS 'Code postal',
a1.city AS 'Ville',
y1.name AS 'Pays de facturation',
a1.phone AS 'Telephone fixe facturation',
a1.phone_mobile AS 'Telephone mobile facturation',
c1.email AS 'Email',
c1.newsletter AS 'Newsletter',
c1.optin AS 'Newsletter groupe',
c2.id_gender AS 'Civilite livraison',
CONCAT_WS(' ',a2.lastname, a2.firstname) AS 'Destinataire',
a2.address1 AS 'Addresse 1',
a2.address2 AS 'Addresse 2',
a2.postcode AS 'CP',
a2.city AS 'Commune',
n.iso_code AS 'Pays',
a2.phone AS 'Telephone',
a2.other AS 'Instructions'
od.product_id AS 'id_prod',
od.product_reference AS 'Ref',
od.product_name AS 'name',
od.unit_price_tax_excl AS 'prix_unitaire',
SUM(od.product_quantity) - SUM(od.product_quantity_return)) Qte_vendue
FROM ps_order_detail od, ps_customer c1, ps_customer c2, ps_address a1, ps_address a2, ps_country_lang y1, ps_country_lang y2, ps_country n, ps_product_lang p, ps_cart_product r, ps_orders o LEFT JOIN ps_orders o ON o.id_order = od.id_order
WHERE o.current_state IN (2, 3, 4, 5, 12, 13, 14, 22)
AND o.id_address_invoice=a1.id_address
AND o.id_address_delivery=a2.id_address
AND o.id_cart = r.id_cart
AND r.id_product = p.id_product
AND p.id_lang=1
AND a1.id_country = y1.id_country
AND a2.id_country = y2.id_country
AND y1.id_lang=1
AND y2.id_lang=1
AND a1.id_customer=c1.id_customer
AND a2.id_customer=c2.id_customer
AND a2.id_country=n.id_country
GROUP BY date_cmde, od.product_id
ORDER BY date_cmde DESC