統計 Oracle按天統計(詳細)

2021-09-30 14:58:32 字數 678 閱讀 1379

--建立表 test

cteate table test(

id number not null,

modifiedtime date not null )

--按天統計

select to_char(t.modifiedtime,'yyyy-mm-dd') time,count(*) count

from test t

--這裡可加查詢條件 where to_char(t.modifiedtime,'yyyy') = to_char(sysdate,'yyyy')

group by to_char(t.modifiedtime,'yyyy-mm-dd') --根據日期來分組

order by to_char(t.modifiedtime,'yyyy-mm-dd') asc nulls last --根據日期排序

--注:modifiedtime 為 表test裡的時間字段,時間型別

--以上**可直接在資料庫裡執行

--假如表裡還有個數量的字段,要按天統計數量,可將count(*)改為sum(1)函式

【統計】oracle按周統計(詳細)

【統計】oracle按月統計(詳細)

【統計】oracle按季度統計(詳細)

【統計】oracle按年統計(詳細)

【統計】按照時間統計總結

統計 Oracle按天統計(詳細)

建立表 test cteate table test id number not null,modifiedtime date not null 按天統計 select to char t.modifiedtime,yyyy mm dd time,count count from test t 這裡...

統計 Oracle按周統計(詳細)

建立表 test cteate table test id number not null,modifiedtime date not null 按周統計 select to char t.modifiedtime,yyyy year,to char t.modifiedtime,iw time,c...

統計 Oracle按周統計(詳細)

建立表 test cteate table test id number not null,modifiedtime date not null 按周統計 select to char t.modifiedtime,yyyy year,to char t.modifiedtime,iw time,c...