我正在尝试编写一个查询,该查询返回使用SQLite在每个州花费最高钱的前5名客户,而我的代码没有这样做。我该如何运作?
SELECT name, state, transact_amt,
FROM
customers
JOIN
transactions
ON customers.customer_id = transactions.customer_id
DENSE_RANK () OVER (
PARTITION BY state
ORDER BY transact_amt
)rn
SELECT name, state, transact_amt
WHERE rn <= 5;