oneday
oneday

Reputation: 671

Joining table with unique id and timestamp

I have 2 tables. Unique id is users whose data is uploaded at a particular timestamp with some values

Table 1

Unique id  timestamp val1 val2
1            50        d   c
2            50        d   e
3            65        a   b
1            65        d   e
2            70        a   d
3            85        c   d

Select *, row_number() over partition by (Unique id order by timestamp) from Table 1

Table 2

    Unique id  timestamp val3 val4
1            10        d   c
2            20        d   e
3            30        a   b
1            75        d   e
2            50        a   d
3            65        c   d

Output Table

Unique id  timestamp val1 val2 val 3 val4
1            10                  d   c
1            50        d   c
1            65        d   e
1            75                  d   e
2            20        d   e
2            50        d   e     a   b
2            70        a   b
3            30                  a   b
3            65        a   b     c   d
3            85        c   d

I am able to partition by unique id and order by ts within a table however unable to join two tables and partition by unique id and order by ts

Upvotes: 0

Views: 33

Answers (0)

Related Questions