![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Say I, in MySQL 4.1, have a table "test" with a single column - "test". There are four rows in the table - 3, 2, 1, and null. Running "SELECT * FROM test ORDER BY test DESC" yields the following: 3 2 1 null Whereas doing it by ASC yields this: null 1 2 3 Since null's aren't supposed to be comparable, it seems that ORDER BYs treatment of them is sorta arbitrary. If so, maybe that "treatment" can be changed? eg. maybe I could make DESC yield this: 3 2 1 null and ASC yield this?: 1 2 3 null Is using UNIONs or JOINs the only way to achieve this effect? |
#3
| |||
| |||
|
|
Since null's aren't supposed to be comparable, it seems that ORDER BYs treatment of them is sorta arbitrary. |
|
If so, maybe that "treatment" can be changed? eg. maybe I could make DESC yield this: |
#4
| |||
| |||
|
|
Since null's aren't supposed to be comparable, it seems that ORDER BYs treatment of them is sorta arbitrary. The original phrase fromt he ANSI/ISO Standards is "implementation defined" and early products did it differently, mostly based on their internal model for NULLs. If so, maybe that "treatment" can be changed? eg. maybe I could make DESC yield this: Use a COALESCE() or a product with the newer sorting options on the ORDER BY clause. How universal is COALESCE's support? Based on a Google search, it |

#5
| |||
| |||
|
|
How universal is COALESCE's support? Based on a Google search, it looks as though MSSQL, PostgreSQL, and MySQL support it, whereas IF and ISNULL, together, only seem to be supported by MySQL. Is it as ubiquitous as the COUNT aggregate function is? If it isn't, that's okay - I'm just curious, heh ![]() |
#6
| |||
| |||
|
|
Say I, in MySQL 4.1, have a table "test" with a single column - "test". There are four rows in the table - 3, 2, 1, and null. Running "SELECT * FROM test ORDER BY test DESC" yields the following: 3 2 1 null Whereas doing it by ASC yields this: null 1 2 3 Since null's aren't supposed to be comparable, it seems that ORDER BYs treatment of them is sorta arbitrary. If so, maybe that "treatment" can be changed? eg. maybe I could make DESC yield this: 3 2 1 null and ASC yield this?: 1 2 3 null Is using UNIONs or JOINs the only way to achieve this effect? |
#7
| |||
| |||
|
|
How universal is COALESCE's support? |
![]() |
| Thread Tools | |
| Display Modes | |
| |