Can someone help me rectify this query? Using Oracle 12C
Trying to Pick Latest Activity date for each Customer Per state to use as subquery to gather rest of the data
Here is example data
Customer_no | State | Activity_date |
110913 | CT | 8/2/2019 |
110913 | MA | 9/22/2020 |
110913 | MA | 11/23/2020 |
110913 | MA | 11/23/2020 |
Desired result
Customer_no | State | Activity_date |
110913 | CT | 8/2/2019 |
110913 | MA | 11/23/2020 |
The query I write is following: looks like max() can’t pick one from same activity_date
Distinct is also not working…
select customer_no,tax_State,max(activity_date)
from table
where customer_no ='110913'
group by customer_no,tax_State
and it bring this data
Customer_no | State | Activity_date |
110913 | CT | 8/2/2019 |
110913 | MA | 9/22/2020 |