Livebos视图

create or replace view t_sys_period
(id, fno, fname, ftype, fstartdate, fenddate)
as
select 1||YEAR || case when (MONTH<10) then '0' else '' end ||MONTH|| case when (DAY<10) then '0' else '' end ||DAY,'Y'||YEAR ||'M'||case when (MONTH<10) then '0' else '' end ||MONTH||'D'||case when (DAY<10) then '0' else '' end ||DAY, YEAR ||'年'||case when (MONTH<10) then '0' else '' end ||MONTH||'月'||case when (DAY<10) then '0' else '' end ||DAY||'日',1,RQ,RQ from tcalendar
union
select 2||YEAR || case when (NOOFWEEK<10) then '0' else '' end ||NOOFWEEK,'Y'||YEAR ||'W' || case when (NOOFWEEK<10) then '0' else '' end ||NOOFWEEK, YEAR ||'年第' || case when (NOOFWEEK<10) then '0' else '' end ||NOOFWEEK ||'周',2,
case when NOOFWEEK=1 and count(week)<7 then (select max(rq) from tcalendar where week=1 and month=12 and year=t.year-1 ) else  min(RQ) end,max(RQ)
from tcalendar t
having (case when NOOFWEEK>50 and count(week)<>7 then 0 else 1 end)=1
 group by YEAR ,NOOFWEEK
union
select 3||YEAR || case when (MONTH<10) then '0' else '' end ||MONTH,'Y'||YEAR ||'M' || case when (MONTH<10) then '0' else '' end ||MONTH, YEAR ||'年' || case when (MONTH<10) then '0' else '' end ||MONTH ||'月',3,min(RQ),max(RQ) from tcalendar group by YEAR ,MONTH
union
select 4||YEAR ||Quarter, 'Y'||YEAR ||'Q'||Quarter,YEAR ||'年第' ||Quarter ||'季度',4,min(RQ),max(RQ) from tcalendar group by YEAR ,Quarter
union
select 5||YEAR, 'Y'||YEAR,YEAR  ||'年',5,min(RQ),max(RQ) from tcalendar group by YEAR;

转载于:https://www.cnblogs.com/luhanzhen/p/8624711.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值