oracle中怎麼查這個月每週的數量

2021-10-03 14:42:38 字數 2833 閱讀 1089

第一周:

select count(0) num,'第一周' as name from t_customer t where t.register_time between 

trunc(sysdate,'mm') and trunc(sysdate,'mm')+7

第二週:

select count(0) num,'第二週' as name from t_customer t where t.register_time between 

trunc(sysdate,'mm')+7 and trunc(sysdate,'mm')+14

第三週:

select count(0) num,'第三週' as name from t_customer t where t.register_time between 

trunc(sysdate,'mm')+14 and trunc(sysdate,'mm')+21

第四周:

select count(0) num,'第四周' as name from t_customer t where t.register_time between 

trunc(sysdate,'mm')+21 and trunc(sysdate,'mm')+28

第五周(最後一周):

select count(0) num,'第五周' as name from t_customer t where t.register_time between 

trunc(sysdate,'mm')+28 and trunc(last_day(sysdate),'dd')+1

union:

沒有按順序

---沒有按順序--

select num,name from (

select count(0) num,'第一周' as name from t_customer t where t.register_time between

trunc(sysdate,'mm') and trunc(sysdate,'mm')+7

union

select count(0) num,'第二週' as name from t_customer t where t.register_time between

trunc(sysdate,'mm')+7 and trunc(sysdate,'mm')+14

union

select count(0) num,'第三週' as name from t_customer t where t.register_time between

trunc(sysdate,'mm')+14 and trunc(sysdate,'mm')+21

union

select count(0) num,'第四周' as name from t_customer t where t.register_time between

trunc(sysdate,'mm')+21 and trunc(sysdate,'mm')+28

union

select count(0) num,'第五周' as name from t_customer t where t.register_time between

trunc(sysdate,'mm')+28 and trunc(last_day(sysdate),'dd')+1

)order by name;

按順序:

---按順序

select num,name,ord from (

select count(0) num,'第一周' as name,1 as ord from t_customer t where t.register_time between

trunc(sysdate,'mm') and trunc(sysdate,'mm')+7

union

select count(0) num,'第二週' as name,2 as ord from t_customer t where t.register_time between

trunc(sysdate,'mm')+7 and trunc(sysdate,'mm')+14

union

select count(0) num,'第三週' as name,3 as ord from t_customer t where t.register_time between

trunc(sysdate,'mm')+14 and trunc(sysdate,'mm')+21

union

select count(0) num,'第四周' as name,4 as ord from t_customer t where t.register_time between

trunc(sysdate,'mm')+21 and trunc(sysdate,'mm')+28

union

select count(0) num,'第五周' as name,5 as ord from t_customer t where t.register_time between

trunc(sysdate,'mm')+28 and trunc(last_day(sysdate),'dd')+1

)order by ord;

Oracle中 Instr 這個函式

sql charindex 字串 字段 0 charindex administrator muserid 0 oracle instr 字段,字串 1,1 0 instr muserid,administrator 1,1 0 在專案中用到了oracle中 instr 這個函式,順便仔細的再次學習...

jsp中 name 這個怎麼用的

這是乙個 el表示式 取值的方法.我舉乙個具體的例子吧 比如有a頁面請求b頁面,在a頁面中有一句這樣的 string name 測試 request.setattribute name name 那麼b頁面中將這樣可以取到name中的資料 這個輸出的值應該是 測試 當然不一定要放在request中可...

oracle 資料庫服務名怎麼查

windows上,直接看 服務裡的 服務名就好 oracle sid service 中間的sid就是資料庫服務的名稱。linux系統下,輸入 env grep sid 可以檢視到,一般沒換都是這個。也可以 ps ef grep ora 這樣來檢視 windows上,直接看 服務裡的 服務名就好 o...