I'm following along with a video by Ben-Gan called Creative Uses of Apply Operator and he shows this code
Select orderiid, orderdate, nextyear
e))) as a1(orderyear)
r +))) as a2(nextyear)
where orderyear > 2007
He comes up with a result set where the nextyear column is one year later than the orderdate, i.e., if orderdate is 2008-01-01, nextyear is 2009
you can see it video place...
However when I try using it with this code on two different databases 2012 AdventureWorks or AdventureworksLT I use the same code on different column names..
select SalesOrderID, OrderDate, NextOrderYear
cross apply (values(year(OrderDate))) as a1(orderYear)
cross apply (values(year(orderYear + 1))) as a2(NextOrderYear)
where orderYear > 2001
I get the
NextOrderYear as being 1905
Obviously something is not right. Just not sure what?