现在收到以下错误:
ORA-30484: missing window specification for this function
30484. 00000 - "missing window specification for this function"
*Cause: All window functions should be followed by window specification,
like <function>(<argument list>) OVER (<window specification>)
*Action:
Error at Line: 17 Column: 72
更新代码(根据 Aaron Hall 的建议)
select meter_id,
to_char(interval_time_local,'dd-mon-yyyy hh24:mi') as gap_start,
to_char(next_interval_time_local,'dd-mon-yyyy hh24:mi') as gap_finish
from (
select i1.device_id as meter_id
,interval_time_local
,SUM(CASE i1.chan_num WHEN 0 THEN i1.chan_value * 2 ELSE 0 END) as chan0
,SUM(CASE i1.chan_num WHEN 2 THEN i1.chan_value * 2 ELSE 0 END) as chan1
,SUM(CASE i1.chan_num WHEN 1 THEN i1.chan_value * 2 ELSE 0 END) as chan2
,SUM(CASE i1.chan_num WHEN 3 THEN i1.chan_value * 2 ELSE 0 END) as chan3
,lead(interval_time_local,1) over (order by device_id, interval_time_local) as next_interval_time_local
from gn_owner_demo.ami_read_interval i1
where created_utc = ( select max(created_utc)
from gn_owner_demo.ami_read_interval i2
where i2.device_id = i1.device_id
and i2.interval_time_local = i1.interval_time_local)
group by device_id, interval_time_local, i1.device_id, lead(interval_time_local,1)
order by device_id, interval_time_local
)
where interval_time_local <> next_interval_time_local - 30/1440;
我继承了一些提取数据间隙的代码。我从未使用过 OVER 子句,因此不确定它是否正确使用。错误信息是:
ORA-00923: FROM keyword not found where expected
00923. 00000 - "FROM keyword not found where expected"
*Cause:
*Action:
Error at Line: 11 Column: 134
这是查询 - 我在 SQL 开发人员中运行:
select meter_id
,to_char(gn_owner_demo.interval_time_local,'dd-mon-yyyy hh24:mi') as gap_start
,to_char(gn_owner_demo.next_interval_time_local,'dd-mon-yyyy hh24:mi') as gap_finish
from (
select i1.device_id as meter_id
,interval_time_local
,SUM(CASE i1.chan_num WHEN 0 THEN i1.chan_value * 2 ELSE 0 END) as chan0
,SUM(CASE i1.chan_num WHEN 2 THEN i1.chan_value * 2 ELSE 0 END) as chan1
,SUM(CASE i1.chan_num WHEN 1 THEN i1.chan_value * 2 ELSE 0 END) as chan2
,SUM(CASE i1.chan_num WHEN 3 THEN i1.chan_value * 2 ELSE 0 END) as chan3
,lead(gn_owner_demo.interval_time_local,1) over (order by gn_owner_demo.device_id, gn_owner_demo.interval_time_local) gn_owner_demo.next_interval_time_local
from gn_owner_demo.ami_read_interval i1
where gn_owner_demo.created_utc = ( select max(gn_owner_demo.created_utc)
from gn_owner_demo.ami_read_interval i2
where i2.device_id = i1.device_id
and i2.interval_time_local = i1.interval_time_local)
group by gn_owner_demo.device_id, gn_owner_demo.interval_time_local
order by gn_owner_demo.device_id, gn_owner_demo.interval_time_local
)
where gn_owner_demo.interval_time_local <> gn_owner_demo.next_interval_time_local - 30/1440;