• I tried a little bit on solution and got it right :w00t:

    So here is the code

    SELECT t.UserName, t.Drink, t.CreatedDate, x.Value

    FROM #TEMP t

    OUTER APPLY (

    SELECT TOP 1 Value

    FROM

    (

    --SELECT * FROM #TEMP

    SELECT TOP 2 Value , CreatedDate

    FROM #TEMP TI

    WHERE TI.UserName = T.UserName

    AND TI.CreatedDate < T.CreatedDate

    --AND TI.Drink IN ('HardDrink')

    ORDER BY TI.CreatedDate DESC

    ) T

    ORDER BY CreatedDate DESC

    ) x

    WHERE t.Drink IN ('HardDrink')