Select top N records in SQL / Teradata

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

Raymond Tang Raymond Tang 0 10808 4.86 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