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

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -