Categories: Salesforce Marketing CloudSQL Queries

Picking rows with partitions

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


Share
Published by
Adam Spriggs

Recent Posts

  • technology & science

Chevy big block 396 rebuild

https://www.youtube.com/watch?v=z5U5Kxrv6SY Good stuff from Hagerty's #RedlineRebuild series.

6 hours ago
  • sports

Giannis for MVP

3 weeks ago
  • fun
  • technology & science

Artificial Intelligence

4 weeks ago
  • peeves

JUST DON’T

JUST DON'T schedule a meeting for me without checking to see if I'm available JUST DON'T repeatedly propose something to…

1 month ago
  • API
  • Salesforce Marketing Cloud

Triggering Multiple Emails with REST

If you need to trigger one Marketing Cloud email to multiple recipients in a single REST API call, here's how…

1 month ago
  • technology & science

Excavating

https://www.youtube.com/watch?v=RE_dSJh5bvQ via Little Giants Construction Company

3 months ago