I have a SQL database that records operations in a factory. I am trying to get a TOP 1 Order by Date Desc query to also include the previous Date all on one row. I cant for the life of my think how to do this. I have tried a couple of case when statements but I cant seem to get it all on one row. Can anyone help me please?
Current Result
| Operation | Date | 
|---|---|
| AA | 2022-08-15 12:42:34.703 | 
| AA | 2022-08-15 12:37:52.167 | 
Required Result
| Operation | Date | Previous Date | 
|---|---|---|
| AA | 2022-08-15 12:42:34.703 | 2022-08-15 12:37:52.167 | 
Required Result
'ID Date Previous End Date
AA 2022-08-15 12:42:34.703 2022-08-15 12:37:52.167'
 
     
     
     
    