John Try
select field, count(*) from db.table group by field; David > -----Original Message----- > From: John Nichel [mailto:[EMAIL PROTECTED] > Sent: Monday, May 24, 2004 10:37 AM > To: MySQL List > Subject: Query question > > > Hi, > > I have a table which I want to select data from (obiviously). In > this table, I have a field which is an integer, and defaults > to 0. What > I would like to do is count all rows in that table which not > only equals > 0 for the field, but has a distinct value which is greater than 0. > > id field > 1 0 > 2 0 > 3 7 > 4 8 > 5 7 > 6 0 > 7 6 > 8 7 > 9 8 > > For the above example, my count should return 6. Three > zero's count as > 3, three seven's count as 1, two eight's count as 1, and one > six counts > as 1. > > I've tried... > > SELECT COUNT(*) FROM db.table WHERE ( field = 0 || ( field > 0 && > DISTINCT field ) ) > > But it still returns the count of all the rows. > > -- > John C. Nichel > KegWorks.com > 716.856.9675 > [EMAIL PROTECTED] > > -- > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]