Top 5 Records from a table problem

Results 1 to 2 of 2

Thread: Top 5 Records from a table problem

  1. #1
    Join Date
    Dec 1969

    Default Top 5 Records from a table problem

    Hi,<BR><BR>I&#039;ve created a link tracking script which creates a table that shows links stored in a database along with a hit counter showing the number of times the link has been clicked.<BR><BR>I&#039;m using the following SQL script to pull out the top 5 records<BR><BR>SELECT TOP 5 * FROM tblLink ORDER BY fldlinkcounter DESC;<BR><BR>Now, it works fine, but if two records share the same counter value, they are both show<BR><BR>so<BR><BR>record one 3 hits<BR>record two 3 hits<BR>record three 3 hits<BR>record four 3 hits<BR>record five 5 hits<BR>record six 5 hits<BR><BR>So you would expect five, six, four, three and two to show, but one record one.<BR><BR>But it does show.<BR><BR>If there anything I can do to make sure that 5 and only 5 records are shown regardless of whether the hit values are the same or not<BR><BR>Appreciate your help<BR><BR>Thanks<BR><BR>Darren.<BR><BR>

  2. #2
    Join Date
    Dec 1969
    Los Angeles, CA

    Default RE: Top 5 Records from a table problem

    The TOP predicate doesn&#039;t choose between equal values it will give you all fo them<BR><BR>try recordset.maxrecords = 5<BR><BR>then you will only have 5 records in the recordset

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts