Aha! Figured it out... SELECT COUNT(DISTINCT ipAddress) FROM table WHERE initDate >= DATE_ADD(now(), INTERVAL -60 MINUTE) AND id = [whatever id I'm looking for...];
Works semantically like it sounds. Probably the only variation I didn't try before posting! (always works that way...) Thanks, --jeff ----- Original Message ----- From: "Jeff Kilbride" <[EMAIL PROTECTED]> To: "MySQL" <[EMAIL PROTECTED]> Sent: Saturday, March 09, 2002 1:16 PM Subject: SQL question -- can this be done? > I have a table with 3 fields: > > initDate datetime not null > id int unsigned not null > ipAddress int unsigned not null > > I'm trying to find the number of distinct ipAddresses associated with a > particular id over a specified time frame -- for simplicity, let's say the > time frame is the last 60 minutes. So, I use the following query: > > SELECT DISTINCT ipAddress > FROM table > WHERE initDate >= DATE_ADD(now(), INTERVAL -60 MINUTE) > AND id = [whatever id I'm looking for...]; > > This works and returns a result set with one row per distinct ipAddress. In > my program, I can count the number of rows in the result set to get my > answer. My question is this: is there any way to modify this query so it > returns a *count* of the number of distinct ipAddresses, rather than having > a row for each distinct ipAddress in the result set? Can I use some sort of > aggregate function like COUNT() when also specifying DISTINCT? > > I've tried a few different things, but haven't been able to get it to work. > Does anyone know if this can or can't be done? > > Thanks, > --jeff > > > > --------------------------------------------------------------------- > Before posting, please check: > http://www.mysql.com/manual.php (the manual) > http://lists.mysql.com/ (the list archive) > > To request this thread, e-mail <[EMAIL PROTECTED]> > To unsubscribe, e-mail <[EMAIL PROTECTED]> > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php > --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php