Relative Content

Tag Archive for sqlhive

Rank in SQL special case

Write Hive SQL query to get the output from the input shown below.
I am trying to add rank column which is ordered by event_ts. But if there is same item_id for any consecutive rows, they should get the same rank. Partition by item_id will not work here as it will rank each partition window starting from 1. But I want the rank to monotonically increase.