0

In MySQL and other engines I use a statement of the type:

SELECT reference FROM table WHERE field = 'iphone' ORDER BY reference LIMIT 2  OFFSET  0;

But in TeraData I can't find an equivalency to perform a paginated query.

I appreciate your ideas ;)

2

1 Answer 1

1

I found this options

1.

SELECT RANK(reference) as row_num, reference 
  FROM table 
 WHERE field = 'iphone'
ORDER BY 1
QUALIFY row_num  BETWEEN 2 and 4;
SELECT  RANK() OVER (ORDER BY reference) as row_num, reference 
  FROM table 
 WHERE field = 'iphone'
QUALIFY row_num  BETWEEN 2 and 4;

But I'm not sure which one is the best

Sign up to request clarification or add additional context in comments.

2 Comments

Run the select without the qualify, you should be able to see the difference pretty quickly.
#1 is legacy TD-specific syntax; #2 is preferred going forward. Note that if there are duplicate ORDER BY values you may not get exactly the number of rows you expect (but at least you should not skip or repeat rows since duplicates would all be assigned the same RANK)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.