博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
增加工作日排序字段
阅读量:5085 次
发布时间:2019-06-13

本文共 1662 字,大约阅读时间需要 5 分钟。

 

 

1 drop table work_day_tbl; 2 create table work_day_tbl ( 3      day                   string comment '日期' 4     ,week                  int    comment '周一1,周日7' 5     ,work_day              int    comment '1工作日2周末3节假日' 6     ,work_day_rn           int    comment '工作日排序' 7 )  8 stored as orc 9 ;10 11 insert overwrite table work_day_tbl12 select13      t2.day14     ,t2.week15     ,t2.work_day16     ,sum(t2.flag) over(order by t2.day rows between unbounded preceding and current row ) as work_day_rn17 from (18     select19      t1.*20     ,case when work_day = 1 then 1 else 0 end as flag21     from (22         select '2013-08-15' as day,4 as week,1 as work_day union all23         select '2013-08-16' as day,5 as week,1 as work_day union all24         select '2013-08-17' as day,6 as week,2 as work_day union all25         select '2013-08-18' as day,7 as week,2 as work_day union all26         select '2013-08-19' as day,1 as week,1 as work_day union all27         select '2013-08-20' as day,2 as week,1 as work_day union all28         select '2013-08-21' as day,3 as week,1 as work_day union all29         select '2013-08-22' as day,4 as week,1 as work_day union all30         select '2013-08-23' as day,5 as week,1 as work_day union all31         select '2013-08-24' as day,6 as week,2 as work_day union all32         select '2013-08-25' as day,7 as week,2 as work_day union all33         select '2013-08-26' as day,1 as week,1 as work_day union all34         select '2013-08-27' as day,2 as week,1 as work_day union all35         select '2013-08-28' as day,3 as week,1 as work_day36     ) t137 ) t238 ;

 

 

转载于:https://www.cnblogs.com/chenzechao/p/9287521.html

你可能感兴趣的文章
@Column标记持久化详细说明
查看>>
创建本地yum软件源,为本地Package安装Cloudera Manager、Cloudera Hadoop及Impala做准备...
查看>>
mysql8.0.13下载与安装图文教程
查看>>
站立会议08(冲刺2)
查看>>
url查询参数解析
查看>>
http://coolshell.cn/articles/10910.html
查看>>
[转]jsbsim基础概念
查看>>
DIV和SPAN的区别
查看>>
第一次使用cnblogs
查看>>
C#语法糖之 session操作类 asp.net
查看>>
2015 Multi-University Training Contest 3
查看>>
使用Gitblit 在windows 上部署你的Git Server
查看>>
217. Contains Duplicate
查看>>
vue2.0 关于Vue实例的生命周期
查看>>
jenkins 更换主数据目录
查看>>
Silverlight中恼人的g.i.cs错误
查看>>
SQLite 数据库增删改查
查看>>
<s:iterator>的status
查看>>
C++入门--1.0输入输出
查看>>
让搭建在Github Pages上的Hexo博客可以被Google搜索到
查看>>