1
topflop
medina5 edited this page 2025-09-11 07:55:04 +02:00

Tops / Flops

Afficher le nombre de personnes qui ont acheté le top 5 des articles les plus chers.

WITH top5 AS (
    SELECT code
    FROM article
    ORDER BY prix DESC
    LIMIT 5
)
SELECT COUNT(DISTINCT t.adherent_id) AS nb_clients_top5
FROM ligne l
JOIN ticket t ON t.id = l.ticket_id
WHERE l.article_code IN (SELECT code FROM top5);