Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 01-30-2007, 06:17 PM   #1
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?

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
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?


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:01 PM.

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