All pastes #16278 Raw Edit

coder

public text v1 · immutable
#16278 ·published 2005-06-29 07:57 UTC
rendered paste body
mysql> SELECT COUNT(*) AS num,author FROM comments GROUP BY author ORDER BY num DESC LIMIT 0,10;
+-----+----------+
| num | author   |
+-----+----------+
| 148 | coder    |
| 108 | pollo    |
|  78 | r0sk     |
|  74 |          |
|  58 | Dalloway |
|  42 | krs      |
|  42 | Aloriel  |
|  37 | Felipe   |
|  36 | QuasaR   |
|  25 | Ruben    |
+-----+----------+
10 rows in set (0.14 sec)

That works fine until I apply a CASE to avoid the blank in the author field:

mysql> SELECT COUNT(*) AS num,case author when '' then 'anon' end FROM comments GROUP BY author ORDER BY num DESC LIMIT 0,10;
+-----+-------------------------------------+
| num | case author when '' then 'anon' end |
+-----+-------------------------------------+
| 148 | NULL                                |
| 108 | NULL                                |
|  78 | NULL                                |
|  74 | anon                                |
|  58 | NULL                                |
|  42 | NULL                                |
|  42 | NULL                                |
|  37 | NULL                                |
|  36 | NULL                                |
|  25 | NULL                                |
+-----+-------------------------------------+
10 rows in set (0.15 sec)

As you can see, all the rest get corrupted