the code given was
is the ';with cte as...' part of the solution? Is this a syntax that only applies to SQL2005 and up? If so, can somebody please explain briefly what that is or just point me in the direction of an article or blog post or even what I would call that to search for further explanation?
Thanks,
Willie
Code:
;with cte as (select *, row_number() over (partition by ItemNo
order by Date DESC) as Row from ItemsInfo)
select T.ItemNo, P.Price as PrevPrice, P.[Date] as PrevDate,
T.Price as CurrentPrice, T.[Date] as CurrentDate
from Cte T LEFT JOIN cte P on T.ItemNo = P.ItemNo and T.Row = 1
and P.Row = 2
is the ';with cte as...' part of the solution? Is this a syntax that only applies to SQL2005 and up? If so, can somebody please explain briefly what that is or just point me in the direction of an article or blog post or even what I would call that to search for further explanation?
Thanks,
Willie