'Question on SQL Aggregation - error to show data only
I'm trying to aggregate to show the earliest rejected (case #, created_on, status, and amount) and approved rows within the same case#. When I put a min() function to return the earliest rejected transaction, it returns an error. Can anyone help?
[raw data]

[expected result]

Solution 1:[1]
here is one way :
select * from (
select * , rank() over (partition by case_num, status order by created_on) as rn
from tablename
) t where t.rn = 1
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | eshirvana |
