Search code examples
sqldb2rownum

How to fix "function not allowed" when using row_number() over a view?


select * from       (                                                   
select a.*,row_number() over() as rk                                    
from table1 tba  
                     ) as foo where rk between 11 and 20  

This works for database table. I am using a view which is a join of 2 tables. When i try to do rownum it is saying: "Function not allowed"

select * from       (                                                   
select a.*,row_number() over() as rk                                    
from view1 v1  
                     ) as foo where rk between 11 and 20  

Any suggestion or alternative for rownum in DB2?


Solution

  • You should include the row_number() in your view