You can also get a percentage of the records:
sel * from emp sample .05;
This will return 5% of the records from table emp. (if you have qualified records using where condition(s) the percent of records returned is based on total number of records meeting criteria).
In Teradata there is a concept of rowid as in Oracle where in we know that the row has been inserted in which sequence. In TD rows are stored randomly on different AMPs and there is no way to know which one was inserted first except if you put in a time stamp in a record. So Sample 5 will not give you first 5 rows of a table.
e.g. A table t2 has d1,d2,d3 integer columns having data as
1 2 3
4 5 6
7 8 9
10 11 12
13 14 15
16 17 18
19 20 21
22 23 24
25 26 27
28 29 30
Now fire statements like
sel * from t2 sample 4;
*** Query completed. 4 rows found. 3 columns returned.
*** Total elapsed time was 1 second.
I wrongly gave the explanation of RANDOM fn in earlier example. Actually in the sql stmt below a random no between 1 and 100 is generated by the system and if it is less than 30 that row is returned to the user.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.