retrieve popular search items from SQL 2000 table - problems

Discussion in 'Databases' started by RabBell, Jul 10, 2007.

  1. #1
    I've been using SQL for a while but I'm kinda stumped as to where to start with this one. I have a search function on my ecommerce site and whatever anyone searches for is being stored in a database.

    I need a script that will look at my search entries table and return a list of the most popular search terms.

    So go to the table and produce result like

    Search Term (count)
    Harry Potter (6)
    Sherlock Holmes (4)
    Garfield (2)

    But like I say, I'm a little stumped as to where to even begin with this one.
     
    RabBell, Jul 10, 2007 IP
  2. flippers.be

    flippers.be Peon

    Messages:
    432
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    select top(10) columnname, count(*) from tablename
    group by columnname
    order by count(*) desc
     
    flippers.be, Jul 10, 2007 IP
  3. RabBell

    RabBell Guest

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thank you :)
     
    RabBell, Jul 10, 2007 IP