Monday 7 October 2013

03. Write a query to return the current year price and the previous year price of a product with the Product ID, 715, over subsequent years.

select ProductID, Year(StarDate)
as
salesYear, ListPrice as CurrentPrice, LAG(ListPrice,1,0)
Over(Order by year(startDate))
as PreviousPrice from Production.ProductListPriceHistory
where ProductID=715

No comments:

Post a Comment