Thanks for everybody's help!!
This way worked for me.  Clever!

Chris

... and yes... even my example was messed up
:-P

-----Original Message-----
From: Rudy Metzger [mailto:[EMAIL PROTECTED]
Sent: Monday, July 14, 2003 4:15 AM
To: Christopher Knight; MySQL List
Subject: RE: grouping / sorting etc..


SELECT col1, IF(count(*)!=count(col2),NULL,'BAD')
  FROM table1
 GROUP BY col1;

This ONLY works EXACLTY for the case you submitted.

Please note that your example is wrong (I think). 3 should also return
NULL, shouldn't it?

/rudy



-----Original Message-----
From: Christopher Knight [mailto:[EMAIL PROTECTED] 
Sent: vrijdag 11 juli 2003 17:32
To: MySQL List
Subject: grouping / sorting etc..

Im having troubles getting the results I want... can someone suggest
which way to go..
mysql 4.0

A
------------
| 1 |      |
| 1 | BAD  |
| 2 |      |
| 3 | BAD  |
| 3 |      |
| 4 | BAD  |
| 5 |      |
| 5 | BAD  |
| 5 | BAD  |
------------

what I want is 5 results.  If there is a NULL, then return the NULL,
else return the BAD

so basically return ...
------------
| 1 |      |
| 2 |      |
| 3 | BAD  |
| 4 | BAD  |
| 5 |      |
------------

Ive tried 

        select * from table group by 1stcolumn = (unpredicatble results,
but returns 5 rows)
        select * from talbe groub by 1stcolumn, 2ndcolumn = (returns 8
rows)

I could do the 2nd way then filter out w/ the code...
Is there a better way?
Thanks
Chris


-- 
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]



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to