Over函数不能单独使用,要和分析函数:rank(),dense_rank(),row_number()等一起使用。
其参数:over(partition by columnname1 order by columnname2)
含义:其中PARTITION BY 为分组字段,ORDER BY 指定排序字段
1:select row_number()over(order by id) as RowNum,* from book;
结果:
2:select sum(id)over(partition by bgroup) as bSum,* from book;
结果:(每一行都可以看到bSum和的结果)