I’m constantly faced with situations with data in Salesforce Marketing Cloud where I need to select or identify rows based on some ordered criteria. The row_number() over (partition by x order by y) as ranking is my go-to method.

This particular query finds a random row for each bounce category in the _bounce data view:

See the gist on github.

Recently, found this shorter method:

See the gist on github.

Credit @TheGameiswar

Published by
Adam Spriggs @wvpv

Recent Posts

  • AMPScript
  • Salesforce Marketing Cloud
  • Server-side JavaScript

Updating Salesforce Objects with Server-Side JavaScript

If the custom preference center in your integrated Marketing Cloud account needs to update Salesforce object attributes, you're probably acquainted…

2 weeks ago
  • sports

Giannis is the 2018-19 NBA MVP

https://www.youtube.com/watch?v=2OZZp3k_EqI I'm so happy for him and for the future of the Milwaukee Bucks. Always want more but never be…

3 weeks ago
  • food

How to dice an onion

https://youtu.be/CwRttSfnfcc Chef Jean Pierre demonstrates the proper way to dice an onion.

3 weeks ago
  • fun

Wanna box?

Wanna box for those, Sir? Nah, I hate violence. Is it cool if I just pay with my card?

2 months ago
  • fun
  • inspiration

I’ll have what he’s having, part 12

https://www.youtube.com/watch?v=vC8gJ0_9o4M South Pole trekker Aleksander Gamme revisiting a stash he left for himself a month earlier. Be sure and turn…

3 months ago