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.
You can use a GROUP BY and ORDER BY clause in your SQL statement e,g,
DECLARE @.MYTABLETABLE (idint IDENTITY(1,1), SearchTermvarchar(10))INSERT @.MYTABLEVALUES('ASP.NET')INSERT @.MYTABLEVALUES('ASP.NET')INSERT @.MYTABLEVALUES('Something')INSERT @.MYTABLEVALUES('Nothing')INSERT @.MYTABLEVALUES('Anything')INSERT @.MYTABLEVALUES('Other')SELECT SearchTerm,COUNT(id)AS SearchesFROM @.MyTableGROUP BY SearchTermORDER BYCOUNT(id)DESC
No comments:
Post a Comment