Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT
- ChangedDateTime,
- ROW_NUMBER() OVER(PARTITION BY ProductCode, ChangedDateTime ORDER BY ChangedDateTime DESC) change_id,
- ProductCode
- FROM `dataset.table`
- Row ChangedDateTime change_id ProductCode
- 1 2019-06-06 08:08:01.510 UTC 1 A11
- 2 2019-06-05 08:08:01.510 UTC 2 A11
- 3 2019-06-04 16:02:13.087 UTC 1 A11
- 4 2019-06-05 08:08:01.510 UTC 1 A110
- 5 2019-06-04 16:02:13.087 UTC 1 A110
- 6 2019-06-04 14:36:54.930 UTC 1 A110
- Row ChangedDateTime change_id ProductCode
- 1 2019-06-06 08:08:01.510 UTC 1 A11
- 2 2019-06-05 08:08:01.510 UTC 3 A11
- 3 2019-06-04 16:02:13.087 UTC 2 A11
- 4 2019-06-05 08:08:01.510 UTC 1 A110
- 5 2019-06-04 16:02:13.087 UTC 2 A110
- 6 2019-06-04 14:36:54.930 UTC 2 A110
- SELECT
- ChangedDateTime,
- ROW_NUMBER() OVER(PARTITION BY ProductCode ORDER BY ChangedDateTime DESC) change_id,
- ProductCode
- FROM `dataset.table`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement