Je suis désolé, j'ai voulu rendre ma requête plus compréhensible et j'ai supprimé la ligne qui fait référence au coupon :
CODE
SELECT o.customers_id ,SUM(ot.value) as CA
FROM customers c
INNER JOIN orders o on c.customers_id = o.customers_id
INNER JOIN orders_total ot ON o.orders_id = ot.orders_id
INNER JOIN coupon_redeem_track crt ON o.customers_id = crt.customer_id
INNER JOIN coupons cou ON crt.coupon_id = cou.coupon_id
WHERE o.customers_country LIKE "%France (métropolitaine)%"
and o.customers_id IN and ot.title = "Total:"
and cou.coupon_code like "ma-reduc"
group by o.customers_id, o.customers_name, c.customers_email_address, o.customers_country
having SUM(ot.value) > 3000
la table coupon_redeem_track est composé de la manière suivante :
CODE
CREATE TABLE IF NOT EXISTS `coupon_redeem_track` (
`unique_id` int(11) NOT NULL AUTO_INCREMENT,
`coupon_id` int(11) NOT NULL DEFAULT '0',
`customer_id` int(11) NOT NULL DEFAULT '0',
`redeem_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`redeem_ip` varchar(32) NOT NULL DEFAULT '',
`order_id` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`unique_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=167422 ;
et la table coupon de la façon suivante :
CODE
CREATE TABLE IF NOT EXISTS `coupons` (
`coupon_id` int(11) NOT NULL AUTO_INCREMENT,
`coupon_type` char(1) NOT NULL DEFAULT 'F',
`coupon_code` varchar(32) NOT NULL DEFAULT '',
`coupon_amount` decimal(8,4) NOT NULL DEFAULT '0.0000',
`coupon_minimum_order` decimal(8,4) NOT NULL DEFAULT '0.0000',
`coupon_start_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`coupon_expire_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`uses_per_coupon` int(5) NOT NULL DEFAULT '1',
`uses_per_user` int(5) NOT NULL DEFAULT '0',
`restrict_to_products` varchar(255) DEFAULT NULL,
`excl_products` varchar(255) DEFAULT NULL,
`restrict_to_categories` varchar(255) DEFAULT NULL,
`excl_categories` varchar(255) DEFAULT NULL,
`restrict_to_customers` text,
`coupon_active` char(1) NOT NULL DEFAULT 'Y',
`date_created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`date_modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`coupon_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=7277 ;
Je n'ai pas demandé m'aider en me corrigeant ma contribution!!! Il est juste question d'un problème de requêtes!!!!!!!!!!!!!