1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| SELECT SUM(affeng) FROM
(
SELECT count(a.id) as affeng
FROM affaire a
inner JOIN evenement e ON a.id = e.affaire_id and e.type_principal_id = 444
AND e.sous_type_id =477
AND e.date_creation between DATE_SUB(NOW(),INTERVAL 1 YEAR) and NOW()
WHERE
a.client_id in (86261) and a.segment_marche_id != 31
UNION ALL
SELECT count(a.id) as affclot
FROM affaire a
inner JOIN evenement e ON a.id = e.affaire_id and e.type_principal_id = 444
AND e.sous_type_id =479
AND e.jalon_motif_id =441
AND e.date_creation between DATE_SUB(NOW(),INTERVAL 1 YEAR) and NOW()
WHERE
a.client_id in (86261) AND a.segment_marche_id != 31
) AS tmp; |
Partager