Bonjour,

Tout d'abord j'utilise:
Toad for MySQL v.4.1.0.220
MySQL v.5.1

J'aimerai pouvoir compter le nombre de client unique faisant du gratuit et de même avec le payant

Exemple de table:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
CREATE TABLE table_billing (
client integer,
billing_date date,
price integer);
INSERT INTO table_billing VALUES (1456, '2009-01-01', 0);
INSERT INTO table_billing VALUES (4542, '2009-01-01', 30);
INSERT INTO table_billing VALUES (1456, '2009-01-01', 10);
INSERT INTO table_billing VALUES (7894, '2009-01-01', 44);
INSERT INTO table_billing VALUES (4585, '2009-01-01', 55);
INSERT INTO table_billing VALUES (1456, '2009-01-01', 0);
INSERT INTO table_billing VALUES (6527, '2009-01-02', 0);
INSERT INTO table_billing VALUES (3658, '2009-01-02', 91);
INSERT INTO table_billing VALUES (7459, '2009-01-02', 1);
INSERT INTO table_billing VALUES (6310, '2009-01-02', 0);
INSERT INTO table_billing VALUES (7459, '2009-01-02', 100);
INSERT INTO table_billing VALUES (6310, '2009-01-02', 0);
Résultat souhaité
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
 
date           payant  gratuit total
01/01/09	4	1	4
01/01/09	2	2	4
J'ai tenté des syntaxes comme celle-ci mais sans succès

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
SELECT DATE_FORMAT(billing_date, '%m/%d/%y') AS JOUR,
       Count(distinct if(price>0 and client) AS "client unique payant",
       Count(distinct if(price=0 and client) AS "client unique gratuit",
       Count(distinct client) AS "total client unique"
FROM table_billing
GROUP BY JOUR
ORDER BY JOUR
Pourtant je ne dois pas être loin
Si une âme charitable passe par là, merci d'avance!