Click to See Complete Forum and Search --> : GROUP BY Range


rkquest
01-28-2008, 08:17 PM
I'm trying to write a script that reports the number of users in each country. I have a users table that contains an ip address field and another table that contains the ip-ranges of each country. It has 3 significant columns, (1) name of the country (2) ip range start (3) ip range end.

Is it possible to write one SQL statement that will have this result:

1. First column is the name of the country
2. Second column is the number of users within that country's ip-range
3. All countries with no user records will be disregarded

I'm thinking about using GROUP BY but I'm not sure if it's possible to use it with ranges instead of just one column match.

Thanks!