- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
How to get the row number for particular values from hive table: For example i have column name with VAX_NUM and one of the values for this column is 0006756423. I want know the row number for this value. Do the needful. Thanks
- Labels:
-
Apache Hive
Created ‎09-26-2016 01:45 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How to get the row number for particular values from hive table: For example i have column name with VAX_NUM and one of the values for this column is 0006756423. I want know the row number for this value. Do the needful. Thanks
Created ‎09-26-2016 03:51 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I guess you can use something like
SELECT vax_num, rowid FROM (SELECT vax_num, ROW_NUMBER() OVER() AS rowid FROM <table_name>) <temporary_table_name> WHERE vax_num=0006756423
To give an example for the above:
SELECT id, rowid FROM (SELECT id, row_number() over() AS rowid FROM id_table) id_table_temp WHERE id=17; INFO : Session is already open INFO : Dag name: select id, rowid FROM (select id,...id=17(Stage-1) INFO : INFO : Status: Running (Executing on YARN cluster with App id application_1474453714086_0008) INFO : Map 1: 0/1 Reducer 2: 0/2 INFO : Map 1: 0(+1)/1 Reducer 2: 0/2 INFO : Map 1: 0(+1)/1 Reducer 2: 0/2 INFO : Map 1: 0(+1)/1 Reducer 2: 0/2 INFO : Map 1: 1/1 Reducer 2: 0/2 INFO : Map 1: 1/1 Reducer 2: 0(+1)/1 INFO : Map 1: 1/1 Reducer 2: 1/1 +------+--------+--+ | id | rowid | +------+--------+--+ | 17 | 5 | +------+--------+--+ 1 row selected (12.202 seconds)
Please refer to: https://cwiki.apache.org/confluence/display/Hive/LanguageManual+WindowingAndAnalytics and Apache Hive Cookbook
Created ‎09-26-2016 03:51 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I guess you can use something like
SELECT vax_num, rowid FROM (SELECT vax_num, ROW_NUMBER() OVER() AS rowid FROM <table_name>) <temporary_table_name> WHERE vax_num=0006756423
To give an example for the above:
SELECT id, rowid FROM (SELECT id, row_number() over() AS rowid FROM id_table) id_table_temp WHERE id=17; INFO : Session is already open INFO : Dag name: select id, rowid FROM (select id,...id=17(Stage-1) INFO : INFO : Status: Running (Executing on YARN cluster with App id application_1474453714086_0008) INFO : Map 1: 0/1 Reducer 2: 0/2 INFO : Map 1: 0(+1)/1 Reducer 2: 0/2 INFO : Map 1: 0(+1)/1 Reducer 2: 0/2 INFO : Map 1: 0(+1)/1 Reducer 2: 0/2 INFO : Map 1: 1/1 Reducer 2: 0/2 INFO : Map 1: 1/1 Reducer 2: 0(+1)/1 INFO : Map 1: 1/1 Reducer 2: 1/1 +------+--------+--+ | id | rowid | +------+--------+--+ | 17 | 5 | +------+--------+--+ 1 row selected (12.202 seconds)
Please refer to: https://cwiki.apache.org/confluence/display/Hive/LanguageManual+WindowingAndAnalytics and Apache Hive Cookbook
Created ‎10-03-2016 06:18 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is this issue resolved?
Created ‎10-03-2016 10:10 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yess.. Thanks Ayub
Created ‎10-03-2016 10:40 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Sundar Lakshmanan If "Yess", can you please accept Ayub's answer to help us manage answered questions. Tnx!
