with x as(select
to_char(everyday,'yyyy-mm') as ym,
to_char(everyday,'yyyy') as year,
to_char(everyday,'mm') as month,
case
when to_char(everyday,'mm')='01' and to_char(everyday,'iw')='53' and to_char(everyday,'dy')!='星期日' then 0
when to_char(everyday,'mm')='01' and to_char(everyday,'iw')='53' and to_char(everyday,'dy')='星期日' and to_char(everyday,'dd')='01' then 0
when to_char(everyday,'mm')='01' and to_char(everyday,'iw')='53' and to_char(everyday,'dy')='星期日' then 1
when to_char(everyday,'mm')='01' and to_char(everyday,'iw')='52' then 1
when to_char(everyday,'mmdd')!='0101' and to_char(everyday,'dy')='星期日' then to_number(to_char(everyday,'iw'))+1
when to_char(everyday,'mm')='12' and to_char(everyday,'iw')='01' then 53
else
to_number(to_char(everyday,'iw'))
end as week,
lpad(decode(to_char(everyday,'dy'),'星期日',to_char(everyday,'dd')),3) as 星期日,
lpad(decode(to_char(everyday,'dy'),'星期一',to_char(everyday,'dd')),3) as 星期一,
lpad(decode(to_char(everyday,'dy'),'星期二',to_char(everyday,'dd')),3) as 星期二,
lpad(decode(to_char(everyday,'dy'),'星期三',to_char(everyday,'dd')),3) as 星期三,
lpad(decode(to_char(everyday,'dy'),'星期四',to_char(everyday,'dd')),3) as 星期四,
lpad(decode(to_char(everyday,'dy'),'星期五',to_char(everyday,'dd')),3) as 星期五,
lpad(decode(to_char(everyday,'dy'),'星期六',to_char(everyday,'dd')),3) as 星期六
from(select to_date('20160101','yyyymmdd') + level - 1 as everyday from dual
connect by level <= last_day(to_date('20201201','yyyymmdd'))-to_date('20160101','yyyymmdd')+1
--(last_day(to_date('20061101','yyyymmdd')) - to_date('20061101','yyyymmdd') +1)
))select case when max(星期日)=' 01' or max(星期一)=' 01' or max(星期二)=' 01' or max(星期三)=' 01' or max(星期四)=' 01' or max(星期五)=' 01' or max(星期六)=' 01' then year||'年'||month||'月' else '' end,max(星期日) sun,max(星期一) mon,max(星期二) tue,max(星期三) wed,max(星期四) thu,max(星期五) fri,max(星期六) sat from x group by year,month,week,ym order by year,month,week;
VBA 第14課 自動生成年曆
sub 生成年曆 y inputbox 請指定乙個年份 清除原有內容 range 1 1,4 11,14 21,24 31,34 41 clearcontents 設定標題 cells 1,1 y 年曆 dim dm as variant dm 下標從0開始 dm array 31,28,31,30...
利用oracle儲存過程生成樹編碼
字段 描述 備註 id主鍵,32位uuid type code 編碼如 1 01 003 parent id 父節點id,32位uuid sort num 排序編號 正整數假設頂級節點的type code為字元1,寫儲存過程把表中所有的節點type code生成好 二級節點前面補乙個齡,補兩個零,依...
oracle 生成隨機姓名 Oracle生成隨機碼
本人 交友樂www.jyoule.com 需要經常生成隨機的活動碼,用於製作卡片密碼或通過網路傳送。活動碼的生成規則是採用唯一的字串開頭後面是隨機數字,比如az00001。使用程式生成活動碼速度較慢,但是使用oracle產生活動碼速度極快,而且使用方便。1萬個活動碼只需要2 3秒就可以產生。下面是 ...