The following code works as expected:
select pagenumber from dbo.table1 where (UserID = 5 AND MaterialID = 258 AND PageNumber > 9)
(select pagenumber from dbo.table2 where (UserID = 5 and MaterialID = 258))
In the sense that we get all "pagenumbers" greater than 9 such that they are present at table 1 but not present at table 2.
My question: how could I get ONLY the first pagenumber (I mean, the smaller pagenumber that satisfies this) from this selection?
I´ve tried to put top 1 in the very beginning (as select top 1 pagenumber ...) and it got nothing...
Important: please do not worry about 5 or 258... this numbers will be variables after the problem is solved, of course.