I have table X with UNSIGNED INT column C. I want to order by C ASC,
but have the 0 value last. So, I thought that this should work:
SELECT *, (C-1) AS o from X ORDER BY o;
but it doesn't. Doing a SELECT on (C-1) shows an extremely large
POSITIVE integer value where C=0, as I expected from an UNSIGNED column.
But it is ordered first (as -1). Is this intended behavior? Am I
doing something wrong? I worked around it for now with:
....ORDER BY C>0 DESC, C ASC;
but my curiosity is aroused... And which is faster, anyway?
Thx
P.S. Originally (accidentally) posted in m.d.mysql-win32, sorry
but have the 0 value last. So, I thought that this should work:
SELECT *, (C-1) AS o from X ORDER BY o;
but it doesn't. Doing a SELECT on (C-1) shows an extremely large
POSITIVE integer value where C=0, as I expected from an UNSIGNED column.
But it is ordered first (as -1). Is this intended behavior? Am I
doing something wrong? I worked around it for now with:
....ORDER BY C>0 DESC, C ASC;
but my curiosity is aroused... And which is faster, anyway?
Thx
P.S. Originally (accidentally) posted in m.d.mysql-win32, sorry
Comment