LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-30-2007, 06:17 PM   #1
MicahCarrick
Member
 
Registered: Jul 2004
Distribution: Fedora
Posts: 241

Rep: Reputation: 31
SQL SELECT Group by 2 conditions


I have a table which stores search phrases and IP addresses. I want to execute a query that will give me each search phrase along with the number of unique IPs associated with that phrase. How can I accomplish this "nested" group by?

Code:
SELECT search_phrase, COUNT(*) as c FROM search_tracking GROUP BY search_phrase ORDER BY c DESC
The above obviously groups the search_phrases but does not account for a single user searching for that phrase over and over. Any help?
 
Old 01-30-2007, 10:02 PM   #2
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
Would SELECT DISTINCT... help you here?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Spam limiter for specific conditions. longnshortofit Linux - Security 8 03-12-2006 06:53 PM
Find command using 2 search conditions nifflerX Linux - General 8 07-15-2005 01:37 PM
Sql + Oracle Select If ???? smaida Programming 11 12-15-2004 08:13 PM
Expect test conditions jnusa Programming 0 08-18-2004 04:32 AM
Bizarre SQL select query acid_kewpie Programming 6 01-20-2004 12:47 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:27 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration