Select top N records in SQL / Teradata

Raymond Tang Raymond Tang 10838 4.81 index 5/27/2019

In different databases, the syntax of selecting top N records are slightly different. They may also differ from ISO standards.

In Teradata, use TOPN or SAMPLEto retrieve N records from the table. Remember to replace N with one actual number. As Teradata is a distributed system, SAMPLEwill still scan all the records.

Code snippet

SELECT TOP N * FROM TableName;
SELECT * FROM TableName SAMPLE N;
sql teradata teradata-sql-query

Join the Discussion

View or add your thoughts below

Comments