Reto 1: Ranking de clientes por monto total
Solución
WITH t AS (
SELECT id_cliente, SUM(total) AS monto_total
FROM ventas
GROUP BY id_cliente
)
SELECT t.*,
DENSE_RANK() OVER (ORDER BY monto_total DESC) AS ranking
FROM t
ORDER BY monto_total DESC;