Adding Values From CTE Columns into A Global Temp Table

  • 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;

  • I already soved this problems. It turned out, I had to restart SSMS and it now works.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply