Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Correct Syntax for ROW_NUMBER() in CASE statement in SELECT

Dee102Jun 9 2021

The syntax for
ROW_NUMBER() OVER (PARTITION BY a.member_id ORDER BY trunc(greatest(to_date(b.eff_dt), to_date(b2.eff_dt), to_date(c. eff_dt), to_date(g.plan_eff_dt)), 'MM')) grouping
works, but if I put it in a CASE, it has error. What is the correct syntax?
case
when a.member_id=lag(a.member_id) and a.date1>lag(a.date1)+1 then ROW_NUMBER() OVER (PARTITION BY a.member_id ORDER BY trunc(greatest(to_date(b.eff_dt), to_date(b2.eff_dt), to_date(c. eff_dt), to_date(g.plan_eff_dt)), 'MM'))
else 1
end grouping
The error is
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>)
Thanks.

This post has been answered by Solomon Yakobson on Jun 9 2021
Jump to Answer
Comments
Post Details
Added on Jun 9 2021
3 comments
5,220 views