Re: 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 18:19:04 +0000 (UTC)
Message-ID: <bo8qio$4ri$1_at_sparta.btinternet.com>


> Could you please post that more complicated query?

The more complicated query just has lots of WHERE qualifiers...

SELECT * FROM tblOne WHERE id IN

    (SELECT TOP 3 id FROM tblTwo WHERE

        id NOT IN (SELECT TOP 5 id FROM tblTwo WHERE
                                        fieldA = 'value' AND
                                        fieldB = 'value' AND
                                        (fieldC = 'value' OR fieldD =
'value')
                        ORDER BY id) AND
        fieldA = 'value' AND
        fieldB = 'value' AND
        (fieldC = 'value' OR fieldD = 'value')

    ORDER BY id)

    AND (flags = 'A' OR flags = 'B')

Something like that!

Cheers :o) Received on Tue Nov 04 2003 - 19:19:04 CET

Original text of this message