Best method to SELECT TOP n TO m of a table

From: Will Clark <reply_only_to_newsgroup_please_at_noone-lives-here.com>
Date: Tue, 4 Nov 2003 14:15:04 +0000 (UTC)
Message-ID: <bo8c98$orc$1_at_hercules.btinternet.com>



Hi there,

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?

What I've currently got is...

SELECT TOP 3 * FROM table WHERE

    id NOT IN (SELECT TOP 5 id FROM table ORDER BY id)     ORDER BY id

While this is ok for this (simple) query, it can get quite messy if the query is more complex. There must be a better way of doing it, mustn't there?

Thanks for any help :o)

Will Received on Tue Nov 04 2003 - 15:15:04 CET

Original text of this message