Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2004
    Posts
    162

    Unanswered: count records in a top 10 query

    Hi

    Im trying to make a top 10 list of col1 and and at the 11:th place it should show a number of record that dosent make it to the top 10 list...

    i have this so far, and it dosent give me anything...

    col1 is varchar 254

    SELECT COL1, COUNT(*) AS number
    FROM MYTABLE
    WHERE (NOT EXISTS
    (SELECT TOP 10 COL1
    FROM MYTABLE))
    GROUP BY COL1
    ORDER BY COUNT(*) DESC)

    ex of output

    place1 100
    place2 50
    place3 25
    ...
    place11 500

    a query that only gives me the place11 number is enough

    thx in advance //Mr
    Last edited by mrpcguy; 12-05-05 at 18:11.

  2. #2
    Join Date
    Dec 2003
    Posts
    39
    Here is the number of records that are not in the top 10 list

    select count(*) number
    from myTable
    where col1 not in
    (select top 10 col1 from myTable)
    group by col1
    order by count(*) desc
    )
    Link Link

Posting Permissions

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