zoukankan      html  css  js  c++  java
  • 窗口函数

    create table sales
    (
    year number,
    sales number
    );
    
    insert into sales values (2020,1000);
    insert into sales values (2021,2000);
    insert into sales values (2022,3000);
    insert into sales values (2023,4000);
    insert into sales values (2024,5000);
    
    --unbounded preceding and unbouned following针对当前所有记录的前一条、后一条记录,也就是表中的所有记录
    --unbounded:不受控制的,无限的
    --preceding:在...之前
    --following:在...之后
    rows between unbounded preceding and unbounded following 表中的所有记录 rows between unbounded preceding and current row 是指第一行至当前行的汇总(默认) rows between current row and unbounded following 指当前行到最后一行的汇总 rows between 1 preceding and current row 是指当前行的上一行(rownum-1)到当前行的汇总 rows between 1 preceding and 2 following 是指当前行的上一行(rownum-1)到当前行的下两行(rownum+2)的汇总 select year, sales, sum(sales)over(order by year) a, sum(sales)over(order by year rows between unbounded preceding and unbounded following) b, sum(sales)over(order by year rows between unbounded preceding and current row) c, sum(sales)over(order by year rows between current row and unbounded following) d, sum(sales)over(order by year rows between 1 preceding and current row) e, sum(sales)over(order by year rows between 1 preceding and 2 following) f from sales order by year

      

  • 相关阅读:
    subString用法
    [转]Apache Commons工具集简介
    MyEclipse发布项目更改项目名
    ubuntu下设置文件权限
    mysql数据库中实现内连接、左连接、右连接
    hibernate中onetomany实例一
    hibernate中manytoone实例一
    FireFox中使用ExtJs日期控件错误的解决方法
    Ext.ux.form.SearchField使用方法
    mysql kill操作
  • 原文地址:https://www.cnblogs.com/muzisanshi/p/13223039.html
Copyright © 2011-2022 走看看