I have a list of clients with a Payment ID that has changed over the years, but I'm only interested in returning the info from the most recent. This is my result after running:
Select distinct
a.client
, a.payment_id
, max(a.update_year_month)
from Client_Data a
group by 1,2
| Client | Payment ID | Update Year_Month |
|---|---|---|
| A | B | 202005 |
| A | C | 201907 |
| A | D | 201706 |
I only want my query to pull in the most recent one regardless of the payment_id. However, I need to still bring in Payment ID for my larger query.