Hi I have a SQL QUERY
SELECT ID,ApptDate,OpDate,SacSize,
( SELECT TOP 1 b.SacSize
FROM Table.vAllData as b
WHERE b.ApptDate< a.ApptDate
ORDER BY to_number(b.ID) Desc
) AS Prev_Value
FROM Table.vAllData a where HospNumber='N900001'
the above query Outputs the below, but unfortunatuly i cant get the 'previous_value' column working to populate from the second row, am i missing some thing?
ID | ApptDate | OpDate | SacSize | Prev_Value |
<empty> | 01/01/2013 | 01/01/2013 | 5 | |
1251 | 08/01/2013 | 04/01/2013 | 6 | |
1252 | 10/01/2013 | 10/01/2013 | 3 | 6 |
1253 | 14/01/2013 | 14/01/2013 | 2 | 3 |
1254 | 16/01/2013 | 16/01/2013 | 6 | 2 |
many thanks