SET SESSION group_concat_max_len = 100000;
-- Liste des emails des gens n'ayant pas effectué de paiement en ligne
SELECT GROUP_CONCAT(fu.email SEPARATOR ';'), count(1)
FROM (
SELECT 
    fp.user_id,
    sum(coalesce(jt.timeslotPrice, 9)) as montant_du,
	count(DISTINCT fpt.timeslot_id) as nb_serie
FROM fostt_participants fp
INNER JOIN fostt_participants_timeslots fpt
    ON fpt.participant_id = fp.id
INNER JOIN fostt_options_timeslots ft
    ON ft.timeslot_id = fpt.timeslot_id 	
	AND ft.option_id = 3
CROSS JOIN JSON_TABLE(
    ft.`values`, 
    '$' COLUMNS (
        timeslotPrice DOUBLE PATH '$.timeslotPrice'
    )
) AS jt
WHERE event_id = 184
  AND NOT EXISTS (SELECT 1
				  FROM fostt_options_participants fop 
				  WHERE fop.participant_id = fp.id 
					AND option_id = 3) 
GROUP BY fp.user_id
ORDER BY montant_du DESC
LIMIT 70) as t
	INNER JOIN fostt_users fu ON fu.id = t.user_id
WHERE montant_du > 0
ORDER BY montant_du DESC;


Top 70 : nlassoued@outlook.fr;ingrid597@hotmail.fr;valentin.vb08@laposte.net;mathieu.engelen@hotmail.fr;margot.301299@hotmail.fr;mathr2404@gmail.com;cinheq@gmail.com;gdminnaert@gmail.com;remi.boussd@gmail.com;louis.palie@gmail.com;jeanbaptiste.chetti@gmail.com;liiisalou59@hotmail.com;tablettepas@gmail.com;qk007007@gmail.com;sylvainbiron1994@gmail.com;nefasme@hotmail.com;blanchecourteau@hotmail.com;d.erme@yahoo.fr;dianajulien@sfr.fr;arlane.zhao@gmail.com;vianney.herman@gmail.com;francoisviolette@gmail.com;alessioscarlata12@gmail.com;robinmasselot02@gmail.com;deplix@wanadoo.fr;nathalie.bzdynga@gmail.com;siramybenoit@gmail.com;noalegrand17@gmail.com;hrainbird@proton.me;nicolas.miossec@wanadoo.fr;maxime.dupire59@gmail.com;alex01.janik@gmail.com;raphhgt@gmail.com;defossez.maxime7@gmail.com;dylanbouah@laposte.net;baert.math@gmail.com;samuel.pongiste@gmail.com;maya.leonhardt59288@gmail.com;guillaume.clams@gmail.com;juliencastel26@gmail.com;wissem.mjids@gmail.com;x8z@outlook.fr;pklucas.nguyen@gmail.com;thierry.nguyen@hotmail.


-- Liste des jeunes du fos
SELECT 
    fp.id,
    fp.licence,
    fp.last_name,
    fp.first_name,
    fp.user_id,
    pt.nomclub,
    MAX(CASE WHEN code = 'A' THEN 1 ELSE 0 END) AS A,
    MAX(CASE WHEN code = 'B' THEN 1 ELSE 0 END) AS B,
    MAX(CASE WHEN code = 'D' THEN 1 ELSE 0 END) AS D,
    MAX(CASE WHEN code = 'F' THEN 1 ELSE 0 END) AS F,
    MAX(CASE WHEN code = 'L' THEN 1 ELSE 0 END) AS L,
    MAX(CASE WHEN code = 'M' THEN 1 ELSE 0 END) AS M,
    MAX(CASE WHEN code = 'N' THEN 1 ELSE 0 END) AS N
FROM fostt_participants fp
INNER JOIN fostt_participants_timeslots fpt
    ON fpt.participant_id = fp.id
INNER JOIN fostt_timeslots ft
    ON ft.id = fpt.timeslot_id
INNER JOIN fostt_options_participants fop
    ON fp.id = fop.participant_id 	
	AND fop.option_id = 1
CROSS JOIN JSON_TABLE(
    fop.`values`, 
    '$' COLUMNS (
        nomclub VARCHAR(50) PATH '$.nomclub',
        villesalle VARCHAR(50) PATH '$.villesalle',
        cat  VARCHAR(50) PATH '$.cat'
    )
) AS pt
WHERE fp.event_id = 184
  AND pt.nomclub LIKE '%FOS%'
  AND cat REGEXP '^[PBMCJ]'
GROUP BY fp.id;