|
发表于 2022-4-1 07:40
来自手机
|
显示全部楼层
create temp table 值班日期 as with recursive aa (i,日期,天数) as (select 1 i,date(值班日期始) 日期,天数 from 排班表之四班次做六修二 where rowid=1
union
select aa.i+1 i,date(日期,'+1 day') 日期,天数 from aa where i<aa.天数 ),bb as ( select 班次rowid,row_number() over (partition by 班次 ) 班序,班次,日期 from aa,(select rowid 班次rowid,班次 from 排班表之四班次做六修二)),cc as ( select 班次rowid,(班序+1)/2 班序,班次,日期 from bb), dd as ( select 班次rowid,班序,班次,group_concat(日期) 日期 from cc group by 班序,班次),ee as ( select *,(班序+3)/4 轮次 from dd order by instr('晚白早休',班次)),ff as ( select *,row_number() over (partition by 班次,轮次) 班组rowid from ee ),gg as ( select rowid as 新班组rowid,班组 from 排班表之四班次做六修二),hh as ( select *,iif((班次rowid+班组rowid-1)%4=0,4,(班次rowid+班组rowid-1)%4) 新班组rowid from ff),ii as ( select * from hh left join gg using(新班组rowid)) select 班次,日期,班组 from ii order by instr('早白晚休',班次) ; cli_split_data~值班日期~,~日期; create temp table xaa as select 班次,日期||'<hr>'||strftime('%w',substr(日期,1,10)) 日期,班组 from 值班日期split; cli_create_two_dim~xaa~日期~班次; select * from xaa_two_dim; |
-
|