• Nothing to do with the row_number() I don't think. But I am curious why you are using row_number() in a derived table, and then never using that number.

    You are building a derived table, but when selecting from it you are referring to tables within it instead of the derived table itself.

    From the point of view of your select top 50, the table "exhibitor.dbo.maintable" doesn't exist (its not in the from clause).