select
customer_id,
last_name,
first_name,
email,
active
from
sakila.customer c
order by last_name desc ,first_name desc
limit 10,10;
Now to do the same in Db2 you have to use the ROW_NUMBER() OVER () functions. I didn't have the same table in my AS400(IBM i) Db2 database but you will get the idea. Here is the code snippet
SELECT * from (SELECT p.*,row_number() over() as rn from products as p) as col where rn between 1 and 20
SELECT * from (SELECT p.*,row_number() over(ORDER by weight desc) as rn from products as p) as col where rn between 11 and 20

No comments:
Post a Comment
NO JUNK, Please try to keep this clean and related to the topic at hand.
Comments are for users to ask questions, collaborate or improve on existing.