Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 SQL help reporting on text column
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

lofty
Junior Member

USA
158 Posts

Posted - 31 January 2005 :  19:47:02  Show Profile  Visit lofty's Homepage
Hey,

I have a table that logs internal search queries on my site. Every time someone types something in the search bar, my code logs the search terms, the number of results, and the type of search that is performed (AND, OR, PHRASE). What I want to do is to count the number of times the different search types are used.

I have a column, searchType, that has text in it (each number corresponds to a row in the db):

searchType
1. OR
2. OR
3. OR
4. AND
...etc.

What I want to do is create a report that looks through that column, gets the distinct search types, and then counts each one like this:

AND 67
OR 517
PHRASE 23

If I do a (SELECT DISTINCT searchType FROM Search), I get this:

AND
OR
PHRASE

How can I get a recordset with the counts of the distinct items also?

Thanks,
Adam

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 01 February 2005 :  06:05:37  Show Profile
Try:

SELECT DISTINCT searchType,COUNT(searchType) AS intCount FROM search GROUP BY searchType


Search is your friend
“I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Go to Top of Page

lofty
Junior Member

USA
158 Posts

Posted - 01 February 2005 :  14:40:17  Show Profile  Visit lofty's Homepage
Beautiful, thanks a lot.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.17 seconds. Powered By: Snitz Forums 2000 Version 3.4.07