sql server 2008 - SQL top 1 within WITH statement -


i have sql query makes use of statement. query looks this:

with topage (   select top 1 * ages   order age )  select * topage agegroup = 1 

my question whether where clause gets executed after top statement, because query retrieves no records whereas know there records in database should retrieved.

thanks in advance help.

the answer is: yes, agegroup = 1 predicate applied after selecting top 1. query equivalent this

select * (   select top 1 * ages   order age ) agegroup = 1 

what maybe want this

select top 1 * ages agegroup = 1 order age 

Comments

Popular posts from this blog

javascript - Iterate over array and calculate average values of array-parts -

ASP.NET Javascript: window.open won't work twice -

jquery - Opera does not change the height of the page. Why? -