Big data
Big data

Reputation: 41

Query Hive table using ROWNUM

How can I query a Hive table specific to row number.

For example :

Let say I want to print out all records of Hive table from row number 2 to 5.

Upvotes: 0

Views: 5437

Answers (2)

David דודו Markovitz
David דודו Markovitz

Reputation: 44921

I actually recently updated the documentation regarding the offset option

... order by ... limit 1,4

https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Select#LanguageManualSelect-LIMITClause

Upvotes: 1

n8.
n8.

Reputation: 1738

This answer seems like what you're asking:

SQL most recent using row_number() over partition

In other words:

SELECT user_id, page_name, recent_click
FROM (
  SELECT user_id,
         page_name,
         row_number() over (partition by session_id order by ts desc) as recent_click
  from clicks_data
) T
WHERE recent_click between 2 and 5

Upvotes: 0

Related Questions