Please point out why I am getting errors saying that my CTE columns are invalid. The following is my query.
with QuarterEarning
as(
select Top(2) Product, [Quarter One Earnings], Rank() over
(order by [Quarter One Earnings] asc) as Earnings from dbo.Sales
)
select Product, [Quarter One Earnings] into ##Qtable from QuarterEarning
select ##Qtable.Product, ##Qtable.[Quarter One Earnings] from
##Qtable order by ##Qtable.[Quarter One Earnings] asc;