SHARE
TWEET

Untitled

a guest Jun 18th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT
  2. ChangedDateTime,
  3. ROW_NUMBER() OVER(PARTITION BY ProductCode, ChangedDateTime ORDER BY ChangedDateTime DESC) change_id,
  4. ProductCode
  5. FROM `dataset.table`
  6.      
  7. Row ChangedDateTime change_id   ProductCode
  8. 1   2019-06-06 08:08:01.510 UTC 1   A11
  9. 2   2019-06-05 08:08:01.510 UTC 2   A11
  10. 3   2019-06-04 16:02:13.087 UTC 1   A11
  11. 4   2019-06-05 08:08:01.510 UTC 1   A110
  12. 5   2019-06-04 16:02:13.087 UTC 1   A110
  13. 6   2019-06-04 14:36:54.930 UTC 1   A110
  14.      
  15. Row ChangedDateTime change_id   ProductCode
  16. 1   2019-06-06 08:08:01.510 UTC 1   A11
  17. 2   2019-06-05 08:08:01.510 UTC 3   A11
  18. 3   2019-06-04 16:02:13.087 UTC 2   A11
  19. 4   2019-06-05 08:08:01.510 UTC 1   A110
  20. 5   2019-06-04 16:02:13.087 UTC 2   A110
  21. 6   2019-06-04 14:36:54.930 UTC 2   A110
  22.      
  23. SELECT
  24. ChangedDateTime,
  25. ROW_NUMBER() OVER(PARTITION BY ProductCode ORDER BY ChangedDateTime DESC) change_id,
  26. ProductCode
  27. FROM `dataset.table`
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top