kalyan4uonly
kalyan4uonly

Reputation: 335

How to Implement Hierarchical Query in bigquery

I have some table "tab1", which contains the sample data as like follws

Existed data in the database

I am expecting the output like as follows

Expected output

How to implement in "BIGQUERY", Please help me to achieve this.

Thanks Kalyan

Upvotes: 0

Views: 1140

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269563

I think you just need lead():

select t.*,
       lead(effective_from, 1, date('9999-12-31')) over
           (partition by sno
            order by effective_from
           ) as effective_to
from t

Upvotes: 3

Related Questions