Skip to content
Advertisement

Select the Max row number for an account

I need to only pull the max row number for an account. I know it’s a grouping issue.

Current data:

ACCOUNT_UID ID NAME ACADEMIC_PERIOD CAT_BY_DATE CAT_DATE MAX_ROW
abc abc Popeye 202190 CPT 9/15/2021 1
abc abc Popeye 202190 CSH 10/4/2021 2

I only need the second row.

Current query:

Advertisement

Answer

You can try the following:

The idea is to apply the row_number window function in descending order of transaction_date per every account_uid and pick the first row obtained.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement