On 18 Jun 2002 at 16:36, Walter D. Funk wrote: > Hi everybody! > > I need to count the ACTIVE users of my Mysql users table; where 'active' is > a flag showing this status, > using the following query it returns all the user in the table, and I need > only those who have tha flag active set to 'Y' > > I know this could be done by using a where clause, but in this case it is > not possible, because this is actually only a part of the query and I do not > want to limit the result set with a where clause, > > this is the query I am using, I tried other combinations , but it did not > work :-( > > SELECT IF( STRCMP(active,'Y') = 0 , COUNT(userId) , 0 ) as activeUsers FROM > usersTbl > > > any help will be appreciated, > thanx > Try: SELECT COUNT(IF( STRCMP(active,'Y') = 0 , userId, null)) as activeUsers FROM usersTbl
Regards, Paul --------------------------------------------------------------------- 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