Select top N records in SQL / Teradata

access_time 2 years ago visibility591 comment 0

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

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

Code snippet

SELECT TOP N * FROM TableName;
SELECT * FROM TableName SAMPLE N;
info Last modified by Administrator 6 months ago copyright This page is subject to Site terms.
Like this article?
Share on

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts

More from Kontext

visibility 16563
thumb_up 0
access_time 7 years ago

In this article, I am going to introduce how to install Teradata Express in virtual machines in Windows. 1) Download VMware Player for Windows 32-bit and 64-bit from the following link (version 6.0): https://my.vmware.com/web/vmware/free#desktop_end_user_computing/vmware_player/6_0 This is ...

visibility 1230
thumb_up 0
access_time 5 months ago

Function CURRENT_TIMESTAMP can be used to retrieve the current timestamp: SELECT CURRENT_TIMESTAMP; Sample output: 20/09/2020 20:55:35.390000-04:00 Function CAST can be used to convert TimeStamp to DATE. SELECT CAST(CURRENT_TIMESTAMP AS DATE) Sample output: 20/09/2020 SELECT ...

visibility 10526
thumb_up 0
access_time 4 years ago

This post summarize the common functions that are used when dealing with DateTime datatypes in Teradata.