LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   SQL SELECT Group by 2 conditions (https://www.linuxquestions.org/questions/programming-9/sql-select-group-by-2-conditions-524207/)

MicahCarrick 01-30-2007 06:17 PM

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?

graemef 01-30-2007 10:02 PM

Would SELECT DISTINCT... help you here?


All times are GMT -5. The time now is 07:00 PM.