oracle資料庫sql高手請進來撒某段時間段內

時間 2021-12-19 07:04:19

1樓:校巨集盛

**要這麼複雜....鑑於你按每10分鐘來連續排列有點奇怪..我寫了乙個按照日期來連續的sql..

select b.name, min(b.visit_time), max(b.visit_time)

from (

select a.*, (a.visit_time - rownum) cc

from (

select * from vister order by name, visit_time

) a) b

group by b.name, b.cc;

2樓:匿名使用者

直接用查詢就可以得到你要的結果:

select id,name,visit_time

from

(select id,name,visit_time

,cnt

,max(cnt) over () mx

from

(select id,name,visit_time

,count(mindate) over (partition by mindate) cnt

from

(select id,name,visit_time

,mindate

from

(select id,name,visit_time

,row_number() over (order by visit_time) rn

from vister  t

where t.name = '張三'

) tmodel

dimension by (t.rn)

measures(id,name,visit_time,trunc(visit_time) visit_date,trunc(t.visit_time) as mindate)

rules upsert all

(mindate[any] =

case

when visit_date[currentv()] - visit_date[currentv()-1] <= 1 then

mindate[currentv()-1]

else

visit_date[currentv()]

end)

order by visit_time))

)where cnt = mx

3樓:曾經黃過

我給你個思路吧!相必你基本的orcacl操作都會,因為我沒有裝這相資料,所以也沒有辦法給你寫**!

第一步:先有count(日期),name,日期(格式為年月日) group by 日期,name (對count進行高到低排列)

第二步:取出最高日期,

第三步:顯示最高日期下的詳細資訊;

4樓:匿名使用者

參照一下這個

5樓:匿名使用者

建議使用儲存過程吧。

oracle資料庫查詢某段時間內時間段的資料

6樓:匿名使用者

select * from 表名 where to_date(ip_date,'yyyy.mm.dd') between to_date('20190204','yyyymmdd') and to_date('20190209','yyyymmdd') and substr(ip_time,12,8) between '00:

00:00' and '08:00:00'

7樓:

where date_col between to_date('20190204','yyyymmdd') and to_date('20190209','yyyymmdd')

and to_char(date_col,'hh24') between '00' and '08'

oracle sql語句中怎麼查詢乙個月內固定時間段的資料,比如9月1號到10月1號每天的八點到九點的呼叫數目

8樓:零臨窗聽雨

使用oracle 函式extract(fmt from d)獲取日期中的特定部分:

select count(*) from table where

sql> select * from table where createdate

between to_date('2010-9-1','yyyy-mm-dd') and to_date('2010-10-1','yyyy-mm-dd')

and extract(hour from createdate) between '8:00' and '9:00';

oracle資料庫恢復,oracle資料庫備份,恢復

更改原來d盤的oracle目錄,比如目錄名改成oraclebak,重新安裝oracle資料庫到d盤oracle目錄下,並建立資料庫和原來的資料庫sid保持一致。然後關閉資料庫,把新安裝的資料庫目錄更名或刪除,再把原來的oraclebak目錄再改回oracle,然後重啟一下資料庫,這時的資料庫就是你要...

sql資料庫問題,SQL資料庫問題?

既然用了左連線,那麼a表中極有可能會出現空值,而a.dept 20080203 and a.dept 20080204 and a.status o 卻又將空值排除在外了 我想知道的是,這個外連線究竟起什麼作用呢?看不大出來。有點兒覺得在 left join tn stock as c where ...

資料庫sql題目,資料庫SQL題目

sql資料庫題目 sql資料庫練習題,急求!5 sql資料庫題目誰能給做一下 if object id n member is not null drop table member create table member mid char 10 not null primary key,mname ...

在oracle資料庫中怎麼通過sql語句查詢表的Primary Key

select from dba constraints dc where dc.constraint type p and dc.table name 然後可以用plsql develooper 工具檢視建表sql,就知道對那個字段建立主鍵 select column name from dba c...

關於Oracle資料庫的sql語句請教大家

sql select from test name age school 張三 10 a 張三 14 b 張三 18 c 王二 11 a 王二 15 b 王二 19 c 6 rows selected.sql select name,2 sum decode school,a age,null a,...