Search code examples
sqlsql-order-byteradataaster

How to get sample data from a table or a view in Aster Teradata without using order by?


I am trying to get sample data from a table in Aster Teradata using order by using the following code:

SELECT "col" 
FROM   (SELECT "col", 
               Row_number() 
                 OVER ( 
                   ORDER BY 1) AS RANK 
        FROM   "nisha_test"."test_table") a 
WHERE  rank <= 10000 

I want to get random 10000 rows without using order by.


Solution

  • We can use the LIMIT keyword to get random values from a table or a view in Aster DB.

    select * from "nisha_test"."test_table" limit 10000;