update fee_schedule fs set fs.branch_id=
(
SELECT branch_id FROM (SELECT branch_id
,updated_ts
,gr_number
,row_number() OVER (PARTITION BY gr_number ORDER BY updated_ts desc) AS sno
FROM admission_log ) x
WHERE x.gr_number = fs.gr_number and to_char(x.updated_ts,'yyyymm') < fs.schedule_month
and rownum=1
order by sno
)
where fs.branch_id is null ;
sql错误:ora-00907:缺少右括号00907。00000-“右括号缺失”
我试着用的是同样的东西:
update fee_schedule fs set fs.branch_id=
(
select c.branch_id
from (select b.branch_id,updated_ts,
row_number() over(PARTITION by b.gr_number order by b.updated_ts desc) as Sno
from admission_log b
where b.gr_number = fs.gr_number and to_char(b.updated_ts,'yyyymm') < fs.schedule_month ) c
where c.sno = 1
)
where fs.branch_id is null ;
我发现这个错误:
sql错误:ora-00904:“fs.”“schedule\u month”:标识符无效
1条答案
按热度按时间x33g5p2x1#
你可以用
keep
:此结构相当于“first()”聚合函数,可以方便地绕过oracle对相关子查询的作用域限制。