Hi,
from the below table
prod | runTimeStamp | value |
---|---|---|
ABCD | 8/2/21 12:30 AM** | 101278.52** |
ABCD | 8/3/21 12:30 AM | 101703.52 |
ABCD | 8/7/21 12:30 AM | 101703.52 |
ABCD | 8/8/21 12:30 AM | 101703.52 |
ABCD | 8/9/21 12:30 AM | 101703.52 |
ABCD | 8/18/21 12:30 AM | 108843.52 |
ABCD | 8/23/21 12:30 AM | 108843.52 |
ABCD | 8/24/21 12:30 AM | 108843.52 |
ABCD | 8/25/21 12:30 AM | 108843.52 |
ABCD | 8/26/21 12:30 AM | 108843.52 |
ABCD | 8/27/21 12:30 AM | 108843.52 |
ABCD | 9/3/21 12:30 AM | 113043.52 |
ABCD | 9/6/21 12:30 AM | 113043.52 |
ABCD | 9/7/21 12:30 AM | 113043.52 |
ABCD | 9/22/21 12:30 AM | 167590.56 |
I need to query only when the value changed
|prod|runTimeStamp|current value |previousvalue |
|ABCD|8/2/21 12:30 AM|101278.52|Null|
|ABCD|8/3/21 12:30 AM|101703.52|101278.52|
|ABCD|8/18/21 12:30 AM|108843.52|101703.52|
|ABCD|9/3/21 12:30 AM|113043.52|108843.52|
|ABCD|9/22/21 12:30 AM|167590.56|113043.52|
using row_number() over PARTITION BY ( Prod order by runtimestamp) , I got runtimestamp and current value. Need help in getting the previous value. Any pointer will be of great help
thanks in advance.