共計 2721 個字符,預計需要花費 7 分鐘才能閱讀完成。
這篇文章將為大家詳細講解有關 oracle 日期如何轉換成星期,丸趣 TV 小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。
現在有個數據分析的工作,需要分析網站注冊會員的一些情況:
1. 工作日、工作時間注冊的的會員成為付費會員的比列,
2. 工作日、非工作時間注冊的的會員成為付費會員的比列,
3,非工作日,非工作時間注冊的的會員成為付費會員的比列。
4,非工作日,工作時間注冊的的會員成為付費會員的比列
工作時間按:08:30 到 17:30
工作日:周一到周五。
查看工作日,工作時間的注冊會員總數:
select count(*) from member_info1234 where to_char(register_date, d) 1 and to_char(register_date, d) 7 and to_char(register_date, HH24:mi:ss) 08:00:00 and to_char(register_date, HH24:mi:ss) 17:30:00
注釋:先通過 to_char(sysdate, d) 來把日期轉換成星期的第幾天,具體對照關系如下:
星期日 —-1
星期一 —-2
。
。
星期六 —-7
然后 to_char(register_date, d) 1 and to_char(register_date, d) 7 這樣就選擇出來了工作日。
工作時間就是利用 to_char(register_date, HH24:mi:ss) 08:00:00 and to_char(register_date, HH24:mi:ss) 17:30:00 選擇出來的。
前面四個需求的具體實現如下:
1. 查看工作日,工作時間注冊的會員數
select count(1) from member_info1234 where to_char(register_date, d) 1 and to_char(register_date, d) 7
and to_char(register_date, HH24:mi:ss) 08:00:00 and to_char(register_date, HH24:mi:ss) 17:30:00
2.. 查看工作日,非工作時間注冊的會員數
select count(1) from member_info1234 where to_char(register_date, d) 1 and to_char(register_date, d) 7
and ((to_char(register_date, HH24:mi:ss) 08:00:00 and to_char(register_date, HH24:mi:ss) 00:00:00 )
or (to_char(register_date, HH24:mi:ss) 23:59:59 and to_char(register_date, HH24:mi:ss) 17:30:00 )) ;
3.. 查看非工作日,工作時間注冊的會員數
select count(1) from member_info1234 where (to_char(register_date, d)=1 or to_char(register_date, d)=7)
and to_char(register_date, HH24:mi:ss) 08:00:00 and to_char(register_date, HH24:mi:ss) 17:30:00
4.. 查看非工作日,非工作時間注冊的會員數
select count(1) from member_info1234 where (to_char(register_date, d)=1 or to_char(register_date, d)=7)
and ((to_char(register_date, HH24:mi:ss) 08:00:00 and to_char(register_date, HH24:mi:ss) 00:00:00 )
or (to_char(register_date, HH24:mi:ss) 23:59:59 and to_char(register_date, HH24:mi:ss) 17:30:00
我們從這些數據比例如下:
1. 工作日、工作時間注冊的的會員成為付費會員的比列, —-50605,805 比列為 0.015
2. 工作日、非工作時間注冊的的會員成為付費會員的比列,—-12188,70 比列為 0.0057
3,非工作日,工作時間注冊的的會員成為付費會員的比列。—-7316,82 比列為 0.011
4,非工作日,非工作時間注冊的的會員成為付費會員的比列 —2907 ,19 比列為 0.0065
通過這些比例可以了解到在工作日和工作時間注冊的會員價值最高,成為付費會員的可能性越大,并且可能是因為有的單位周六日也上班,導致非工作日,工作時間注冊的的會員成為付費會員的比列是第二大的,總起來說就是在工作時間注冊的會員,成為付費會員的可能性比較大,可以去告訴業務人員去重點去發展,
關于 to_char 的一些常用的用法:
Select to_char(sysdate, ss) from dual 取當前時間秒部分
Select to_char(sysdate, mi) from dual 取當前時間分鐘部分
Select to_char(sysdate, HH24) from dual 取當前時間秒小時部分
Select to_char(sysdate, DD) from dual 取當前時間日期部分
Select to_char(sysdate, MM) from dual 取當前時間月部分
Select to_char(sysdate, YYYY) from dual 取當前時間年部分
Select to_char(sysdate, w) from dual 取當前時間是一個月中的第幾周 (從 1 日開始算)
Select to_char(sysdate, ww) from dual 取當前時間是一年中的第幾周(從 1.1 開始算)
Select to_char(sysdate, iw) from dual 取當前時間是一年中的第幾周(按實際日歷的)
Select to_char(sysdate, d) from dual 取當前時間是一周的第幾天,從星期天開始,周六結束
Select to_char(sysdate, day) from dual 取當前日是星期幾,和數據庫設置的字符集有關,會輸出 Tuesday
Select to_char(sysdate, ddd) from dual 當前日是一年中的第幾天
關于“oracle 日期如何轉換成星期”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,使各位可以學到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。