I need help to write a query in Oracle to get minimum value for each row, comparing the current row amount with the previous minimum value.
In another word, calculate minimum value for each row from top to that row, dataset for minimum function is from the first row to the current row.
For example: retrieve Min(previous, current) value for each row as below
Rank | Amount | Calc Min (previous, current) |
---|---|---|
1 | 600 | 600 |
2 | 800 | 600 |
3 | 300 | 300 |
4 | 500 | 300 |
5 | 500 | 300 |
6 | 800 | 300 |
7 | 200 | 200 |
8 | 550 | 200 |
Thanks in Advance Ash
You are looking for the analytic function
MIN OVER
.