Chinaunix

标题: ORACLE里, SQL语句请教 [打印本页]

作者: lov    时间: 2005-11-26 21:27
标题: ORACLE里, SQL语句请教
有一表
his_data

结构如下
occur_time  datetime,
value           number(10,2)
occur_time存放的是每分钟采样时间,value是采样值内容如下:

occur_time                                                                 value
=================================================
        2005-11-26 10:00:00                                      29.33
            2005-11-26 10:01:00                                      27.83
            2005-11-26 10:02:00                                      31.20
            2005-11-26 10:03:00                                      32.02
            2005-11-26 10:04:00                                      28.20
            2005-11-26 10:05:00                                      34.02
            2005-11-26 10:06:00                                      32.47
            2005-11-26 10:07:00                                      35.82
            2005-11-26 10:08:00                                      31.70
            2005-11-26 10:09:00                                      35.22
            2005-11-26 10:10:00                                      38.39
            2005-11-26 10:11:00                                      29.93
(以下省略)


请大家帮忙写一SQL,把采样间隔保留5分钟的点,其他的删掉,结果如下
occur_time                                                                 value
=================================================
            2005-11-26 10:00:00                                      29.33
            2005-11-26 10:05:00                                      34.02
            2005-11-26 10:10:00                                      38.39
            2005-11-26 10:15:00                                      42.72
(以下省略)



多谢!
作者: css1978    时间: 2005-11-27 12:06
用一个中间表把间隔5分钟的数据查出来。一句好像还比较难写
作者: sshd    时间: 2005-11-27 14:53
use "substr" to get the minute and "like" to make sure it ends end either 0 or 5.
in 10g use regexp_like
作者: macrodba    时间: 2005-11-28 09:42
学习
作者: ddmmdd    时间: 2005-11-28 10:57
delete from his_data where  substr(to_char(occur_time,'mi'),2,1) not in ('0','5');

试试看。
作者: lov    时间: 2005-11-28 22:23
多谢大家,我搞定了
DELETE FROM his_data WHERE  occur_time NOT LIKE '%0:00' AND occur_time NOT LIKE '%5:00'  ;




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2