SQL Dojo Bêta
Indicateur

Taux d'annulation

Les commandes annulées divisées par toutes les commandes, en pourcentage.
SELECT ROUND(100.0 * COUNT(*) FILTER (WHERE status = 'cancelled') / COUNT(*), 1)
FROM orders;
SELECT COUNT(*) AS orders,
       COUNT(*) FILTER (WHERE status = 'cancelled') AS cancelled,
       ROUND(100.0 * COUNT(*) FILTER (WHERE status = 'cancelled') / COUNT(*), 1) AS cancel_rate_pct
FROM orders;
orderscancelledcancel_rate_pct
25001496.0
L’essayer en Randori