Re: Best method to SELECT TOP n TO m of a table

From: Tom Ivar Helbekkmo <tih+nr_at_eunetnorge.no>
Date: Tue, 04 Nov 2003 19:58:32 +0100
Message-ID: <86oevsdkpz.fsf_at_athene.i.eunet.no>


"Will Clark" <reply_only_to_newsgroup_please_at_noone-lives-here.com> writes:

> I was wondering if there was a better way to do a SELECT where it returns
> not the TOP 5 (or whatever) but, say, the TOP 6 to 8?

I don't recognize this "TOP n" stuff (proprietary to some specific system, I guess?), but the way I'd do it is:

SELECT *
  FROM table AS t
 WHERE (SELECT id FROM table WHERE id < t.id) BETWEEN 5 AND 7;

-tih

-- 
Tom Ivar Helbekkmo, Senior System Administrator, EUnet Norway
www.eunet.no  T: +47-22092958 M: +47-93013940 F: +47-22092901
Received on Tue Nov 04 2003 - 19:58:32 CET

Original text of this message