0

Hi Guys i'm trying to use pagination for my teradata query as below:

SELECT RANK() OVER (ORDER BY id,firstname,lastname,grade,gender,age,profession) as row_num, ORDER BY id,firstname,lastname,grade,gender,age,profession FROM table-1 QUALIFY row_num BETWEEN 0 and 1000 ;

the query works fine. However, i'm trying to see if there is an other way to query the table based on * instead of stating all table columns in query 2 times.

Apprecite your input on this request.

james11
  • 55
  • 6
  • I guess technically you could if you are currently including every column in the table in your order by, but it would be a bad idea. If a column is added, if the order of columns changes, etc, your query would probably break. You basically never want to use `select *` outside of an ad-hoc query. – Andrew Mar 03 '22 at 14:54
  • You can use your alias for your rank column in the query order by - `... from table1 order by qualify between 0 and 100`. – Andrew Mar 03 '22 at 15:00
  • `select * from mytable qualify row_number() over (order by all_Primary_Key_columns) between ...` – dnoeth Mar 03 '22 at 15:01
  • @ Andrew @dnoeth thank you so much guys. this is actually working fine . appreciate your input . – james11 Mar 03 '22 at 21:26

0 Answers0