Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Hive >> mail # user >> need help on writing hive query


Copy link to this message
-
need help on writing hive query
The table format is something like:

user_id    visiting_time      visiting_web_page
user1          time11             page_string_11
user1          time12             page_string_12     with keyword 'abc'
user1          time13             page_string_13
user1          time14             page_string_14     with keyword 'cde'
user1          time15             page_string_15
  ...                ...                       .....
user2          time21             page_string_21
user2          time22             page_string_22
user2          time23             page_string_23     with keyword 'abc'
user2          time24             page_string_24
user2          time25             page_string_25     with keyword 'cde'
   ....              .....                       ....

how to obtain output like:
user1    time14 - time12
user2    time25 - time23
   ...           .............

i.e, we need to first search keyword 'abc' in the visiting_web_page column
to locate the first visiting_time, then search for the second visiting_time
with keyword 'cde', and repeat the procedure for each user...

thanks in advance!