Select top N records in SQL / Hive

access_time 2 years ago visibility4486 comment 0

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

In Hive, use LIMIT N retrieve N records from the table. Remember to change N to an actual number.

Code snippet

info Last modified by Raymond at 2 years 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

Want to publish your article on Kontext?

Learn more

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 SQL local_offer hive

visibility 559
thumb_up 0
access_time 11 months ago

In Oracle database, you can select from dual table if you only want to return a one row result set. In many other databases, the query engine supports select directly from constant values without specifying a table name. 

local_offer teradata local_offer SQL local_offer teradata-sql-query

visibility 3082
thumb_up 0
access_time 3 years ago

For many SQL Server or Oracle developers, you may encounter some inconveniences when writing SQL queries. For example, how to select from dummy table or local defined variables. This page summarize the equivalents in Teradata SQL.

local_offer teradata local_offer SQL local_offer teradata-functions

visibility 230
thumb_up 0
access_time 7 months ago

In SQL Server, TRY_CAST function returns a value cast to a specified data type is the cast is successful or null is the cast is not successful.  In Teradata, the equivalent function is TRYCAST. -- return int 1030 SELECT TRYCAST('01030' AS int); -- return 2019-01-01 as it is a valid date ...

About column

Code snippets for various programming languages/frameworks.

rss_feed Subscribe RSS