Grouping records in SQL

Results 1 to 2 of 2

Thread: Grouping records in SQL

  1. #1
    Join Date
    Dec 1969

    Default Grouping records in SQL

    OK, I have a table in a database that users search on, we track what they are searching for....I am trying to be able to group those search results by a count to see what is the most popular search terms....<BR><BR>So the table looks like this<BR><BR>ID Keyword Results_found TypeOfSearch<BR>__________________________________ ___________________________<BR>1 The Habbit Yes Books<BR>2 Buzz Saw Yes Tools<BR>3 Palm Pilot Yes Electronics<BR>4 The Habbit Yes Books<BR>5 Dell Yes Electronics<BR>6 Palm Pilot Yes Electronics<BR>7 JigSaw Yes Tool<BR>........<BR><BR>Here is the output that I am trying to generate:<BR><BR>Sasy if we ran a query to find most poular in electronics:<BR><BR>Palm Pilot 2<BR>Dell 1<BR><BR><BR>SO I am thinking the SQL would be something like:<BR><BR>SQL = "SELECT count(*) AS count, * FROM tblSearch GROUP BY keyword"<BR><BR>??

  2. #2
    Join Date
    Dec 1969

    Default Can't do select *.

    SQL = "SELECT COUNT([ID]) AS KeywordCount, [Keyword]" & vbCrLf & _<BR> "FROM tblSearch" & vbCrLf & _<BR> "GROUP BY [Keyword]" & vbCrLf<BR>Response.Write "&#060;pre style=&#039;border: 1px inset black;&#039;&#062;" & SQL & "&#060;/pre&#062;"

Posting Permissions

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