標籤:sharp art nbsp 語句 tab to_char 等等 from tar
string sql = "select to_char(StartTime, ‘yyyy‘)||‘-‘|| to_char(StartTime, ‘mm‘)||‘-‘||
to_char(StartTime, ‘dd‘)||‘ ‘|| to_char(StartTime, ‘hh24‘)||‘:‘||
floor(to_char(StartTime, ‘mi‘)/15)*15 statime, sum(Count) as Counts from
table where StartTime <= to_date(‘2016-11-29 18:00:00‘ ,‘YYYY-MM-DD hh24:mi:ss‘)
group by to_char(StartTime, ‘yyyy‘)||‘-‘|| to_char(StartTime, ‘mm‘)||‘-‘||
to_char(StartTime, ‘dd‘)||‘ ‘|| to_char(StartTime, ‘hh24‘)||‘:‘||
floor(to_char(StartTime, ‘mi‘)/15)*15 order by statime";
string sql = "select to_char(StartTime, ‘yyyy‘)||‘-‘|| to_char(StartTime, ‘mm‘)||‘-‘||" + "to_char(StartTime, ‘dd‘)||‘ ‘|| to_char(StartTime, ‘hh24‘)||‘:‘|| " + "floor(to_char(StartTime, ‘mi‘)/15)*15 statime, sum(Count) as Counts" + " from table " + "where StartTime <= to_date(‘2016-11-29 18:00:00‘ ,‘YYYY-MM-DD hh24:mi:ss‘) " + "group by to_char(StartTime, ‘yyyy‘)||‘-‘|| " + "to_char(StartTime, ‘mm‘)||‘-‘|| to_char(StartTime, ‘dd‘)||‘ ‘|| " + "to_char(StartTime, ‘hh24‘)||‘:‘|| floor(to_char(StartTime, ‘mi‘)/15)*15 order by statime";
如上sql語句
StartTime是其中的時間欄位
Count是匯總的欄位,也可以count(*)統計記錄數
table是表名,自己替換
也可以把15改成30,60等等需要統計匯總的分鐘數
oracle 按時間段統計15分鐘內的資料