老师好,
这节里我用以下包含distinct和窗口函数的sql语句1也跑出了正确结果,但是如果把窗口函数提到前面(如sql语句2)就会报错,
sql语句1:
select DISTINCT(name) dname,
count(name) over (partition by 1)
from w_orders
where date_format(time,‘yyyy-MM’)=‘2021-09’;
sql语句2:
select name, count(name) over (partition by 1),
DISTINCT(name) dname
from w_orders
where date_format(time,‘yyyy-MM’)=‘2021-09’;
比较好奇如果像这样select语句中同时出现聚合函数和窗口函数的执行顺序是怎样呢?