[thelist] A Little Query Question

Casey aspnet at thecrookstons.com
Fri Dec 2 16:48:12 CST 2005


Ok, good idea, but thinking it through, the sub query selects the top 20,
 then the main query selects the top 10 from the top 20 -- isn't that the
 same as selecting the top 10?

 But - you gave me an idea.  Is there a SELECT BOTTOM 10?  You could select
 the TOP 20 in the sub query, then select the BOTTOM 10 from that set.  That
 would give you rows 11-20, right?

 Casey

> ----- Original Message ----- 
> From: "Peter Brunone (EasyListBox.com)" <peter at easylistbox.com>
>
>
> There may be a better way, but how about
>
> "SELECT
> TOP 10 FROM (SELECT TOP 20 field1, field2 FROM table1 WHERE... ORDER BY
> field2) ORDER BY field1 "
>
> ?
>
>
> -----Original Message-----
>> From: thelist-bounces at lists.evolt.org On Behalf Of Casey
>>
>> If you wanted to return the top 15 rows from a table, you could say
>> "SELECT
>> TOP 10 FROM table WHERE..."
>>
>> How would you word the query if you wanted rows 11 to 20?
>>
>> (asp.net with MS SQL)
>>
>> Thanks Tim!!!
>>
>> Casey
>>
>>
> 




More information about the thelist mailing list