日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

oracle 查询时间跨度一年,关于时间跨度比较的OVERLAPS函数

發布時間:2024/1/23 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 oracle 查询时间跨度一年,关于时间跨度比较的OVERLAPS函数 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

我曾經在我的博客里介紹了如何使用工作區管理器(workspace)來管理時態。但必須首先配置好工作區管理器。

由于blogdriver空間有問題,所以計劃把博客遷到ITPUB。

SQL>SELECT *

2FROM dual

3WHERE (add_months(sysdate, -6), DATE '2008-08-08')

4OVERLAPS

5(sysdate - 180, interval '2' YEAR);

D

-

X

The OVERLAPS predicate tests

whether two “events” cover a common point in time or not, and has the form.:

(expression,

expression) OVERLAPS (expression, expression)

Each of the two

“events” specified on either side of the OVERLAPS keyword is a period of time

between two specified points on the timeline. The two points can be specified

as a pair of datetime values or as one datetime value and an INTERVAL offset.

Each “event” is

defined by a two expressions constituting a row value expression having two

columns.

The first

column in each row value expression must be a DATE, TIME or TIMESTAMP and the

value in the first column of the first “event” must be comparable.

The second

column in each row value expression may be either a DATE, TIME or TIMESTAMP

that is comparable with the value in the first column or an INTERVAL with a

precision that allows it to be added to the value in the first column.

The value in

the first column of each row value expression defines one of the points on the

timeline for the event.

If the value in

the second column of the row value expression is a datetime, it defines the

other point on the timeline for the event.

If the value in

the second column of the row value expression is an INTERVAL, the other point

on the timeline for the event is defined by adding the values in the two column

of the row value to expression together.

The NULL value

is assumed to be a point that is infinitely late in time.

Either of the

two points may be the earlier point in time.

If the value in

the first column of the row value expression is the NULL value, then this is

assumed to be the later point in time.

從這里,我們可以看出OVERLAPS有兩種用法:

除了本文開始提到的例子外,還有:

SQL> select * from dual

2where(date '2007-01-01',

interval '5' year)

3overlaps (date '2005-01-01',

interval '10' year);

D

-

X

比較的只能是日期,而不是數字,例如:

SQL> select * from dual

2where(1,5)

3overlaps (3,8) ;

where(1,5)

*

ERROR at line 2:

ORA-00932: inconsistent datatypes

由于這個函數是ORACLE的未公開的,所以不宜在產品系統中使用。一個Kevin Meade給出的替代方法:

where (s2 < e1 and e2 > s1) or (s1 < e2 and e1 > s2)

這個函數最早出現在David Aldridge’s的

超強干貨來襲 云風專訪:近40年碼齡,通宵達旦的技術人生

總結

以上是生活随笔為你收集整理的oracle 查询时间跨度一年,关于时间跨度比较的OVERLAPS函数的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。