[thelist] Quick SQL question
.jeff
jeff at members.evolt.org
Mon Feb 10 14:47:01 CST 2003
rob,
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> From: Rob Smith
>
> I want the last 15 or so records from my table, so I try
> this:
>
> SELECT TOP 15 *
> FROM MyTable
> ORDER BY Col_ID DESC
>
> but this returns
>
> 255
> 254
> 253
> 252
> 251
>
> I want it to return
>
> 251
> 252
> 253
> 254
> 255
>
> Do I smell nested queries?
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
perhaps...
SELECT *
FROM MyTable
WHERE Col_ID IN (SELECT TOP 15 Col_ID
FROM MyTable
ORDER BY Col_ID DESC)
ORDER BY Col_ID ASC
kinda icky though.
.jeff
http://evolt.org/
jeff at members.evolt.org
http://members.evolt.org/jeff/
More information about the thelist
mailing list