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:

Recently, found this shorter method using top 1 with ties:

Credit @TheGameiswar


(Visited 2,740 times, 1 visits today)
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments