[thelist] Quick SQL question

.jeff jeff at members.evolt.org
Mon Feb 10 16:48:01 CST 2003


jason,

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> From: Jason Handby
>
> > SELECT *
> >   FROM MyTable
> >  WHERE Col_ID IN (SELECT TOP 15 Col_ID
> >                     FROM MyTable
> >                    ORDER BY Col_ID DESC)
> >  ORDER BY Col_ID ASC
>
> In MS-SQL Server you could also do
>
> 	SELECT * FROM
> 		(SELECT TOP 15 * FROM MyTable
>             ORDER BY Col_ID DESC) MyTable
> 	ORDER BY Col_ID ASC
>
> which gets me an an arguably nicer execution plan than
> your version, although they both seem to run at about
> the same speed.
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

actually, i just ran the results on a table with 8400 records and am seeing
some difference in times.  your version executes consistently about 2/3 of
the time it takes mine to execute.

.jeff

http://evolt.org/
jeff at members.evolt.org
http://members.evolt.org/jeff/




More information about the thelist mailing list