Select top N records in SQL / Teradata

access_time 2 years ago visibility326 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 at 2 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

Kontext Column

Created for everyone to publish data, programming and cloud related articles.
Follow three steps to create your columns.


Learn more arrow_forward

More from Kontext

local_offer teradata

visibility 630
thumb_up 0
access_time 3 years ago

This post summarizes the tutorials I created in the past about Teradata. It is trying to help you gain the basic SQL skills with Teradata especially if you are a new beginner or you just move from SQL Server or Oracle. It also includes some guides about setting up your own Teradata server (latest Teradata Express version TDExpress16.10.00.03_Sles11_40GB.7z).

local_offer hive local_offer SQL local_offer hive-sql-ddl

visibility 25
thumb_up 1
access_time 2 months ago

This page shows how to create Hive tables with storage file format as Parquet, Orc and Avro via Hive SQL (HQL). The following examples show you how to create managed tables and similar syntax can be applied to create external tables if Parquet, Orc or Avro format already exist in HDFS. Example ...

local_offer hive local_offer SQL local_offer hive-sql-ddl

visibility 59
thumb_up 0
access_time 2 months ago

This page shows how to create, drop, and truncate Hive tables via Hive SQL (HQL). Refer to  Differences between Hive External and Internal (Managed) Tables to understand the differences between managed and unmanaged tables in Hive.  Example: CREATE TABLE IF NOT EXISTS ...

About column

Code snippets for various programming languages/frameworks.

rss_feed Subscribe RSS