region_total,
amount / SUM(amount) OVER (PARTITION BY region) as percentage
FROM sales s;
-- 优化后的查询...>= d.date_point
AND s.sale_date point + INTERVAL 1 MONTH
)
SELECT *
FROM monthly_windows...使用适当的窗口范围
-- 不好的实践:使用无限制的窗口
SELECT
sale_date,
amount,
AVG(amount) OVER (
ORDER BY...合理使用分区
-- 不好的实践:过度分区
SELECT
sale_date,
region,
salesperson,
product_id,
amount,...错误:窗口函数的嵌套使用
-- 不正确的查询
SELECT
sale_date,
amount,
ROW_NUMBER() OVER (
ORDER BY