wmsalamanca
New member
- Local time
- Today, 13:37
- Joined
- May 27, 2014
- Messages
- 11
Hello I'm trying to map a previous Fractional value next record. I believe is like adding the carrying forward to the next record.
I have the following query but is not working.
SELECT T1.[Grant Number], Combine.[Vest Date], T1.Per_No, T1.Shares, T1.Fraction, (SELECT TOP 1 Dupe.Fraction
FROM Combine AS Dupe
WHERE Dupe.[Grant Number] = T.[Grant Number]
AND Dupe.[Vest Date] < T1.[Vest Date]
AND Dupe.[Per_No]-T1.[Per_No] = -1
ORDER BY Dupe.[Vest Date] DESC, Dupe.[Grant Number]) AS PriorValue,Combine.[Base Date]
FROM T1
WHERE (((Combine.[Grant Number])="002686"));
Original Table | Query Output | |||||||||
Grant id | Per_No | Vest Date | Shares | Fractional | Grant id | Per_No | Vest Date | Shares | Fractional | |
12345 | 1 | 6/15/2021 | 5.5252 | 0.5252 | 12345 | 1 | 6/15/2021 | 5.5252 | ||
12345 | 2 | 7/15/2021 | 5.5253 | 0.5253 | 12345 | 2 | 7/15/2021 | 5.5253 | 0.5252 | |
12345 | 3 | 8/15/2021 | 5.5254 | 0.5254 | 12345 | 3 | 8/15/2021 | 5.5254 | 0.5253 | |
12345 | 4 | 9/15/2021 | 5.5255 | 5.5255 | 12345 | 4 | 9/15/2021 | 5.5255 | 0.5254 | |
12345 | 5 | 10/15/2021 | 5.5256 | 5.5256 | 12345 | 5 | 10/15/2021 | 5.5256 | 5.5255 | |
12345 | 6 | 11/15/2021 | 5.5257 | 5.5257 | 12345 | 6 | 11/15/2021 | 5.5257 | 5.5256 | |
12345 | 7 | 12/15/2021 | 5.5258 | 0.5258 | 12345 | 7 | 12/15/2021 | 5.5258 | 5.5257 | |
12345 | 8 | 1/15/2022 | 5.5259 | 0.5259 | 12345 | 8 | 1/15/2022 | 5.5259 | 0.5258 |
I have the following query but is not working.
SELECT T1.[Grant Number], Combine.[Vest Date], T1.Per_No, T1.Shares, T1.Fraction, (SELECT TOP 1 Dupe.Fraction
FROM Combine AS Dupe
WHERE Dupe.[Grant Number] = T.[Grant Number]
AND Dupe.[Vest Date] < T1.[Vest Date]
AND Dupe.[Per_No]-T1.[Per_No] = -1
ORDER BY Dupe.[Vest Date] DESC, Dupe.[Grant Number]) AS PriorValue,Combine.[Base Date]
FROM T1
WHERE (((Combine.[Grant Number])="002686"));