Ejemplo: ranking de clientes por monto total

WITH t AS (
  SELECT id_cliente, SUM(total) AS monto_total
  FROM ventas
  GROUP BY id_cliente
)
SELECT t.*,
       RANK() OVER (ORDER BY monto_total DESC) AS rnk,
       DENSE_RANK() OVER (ORDER BY monto_total DESC) AS drnk
FROM t
ORDER BY monto_total DESC;