Informix Null value
Posted in 2006
Topics: General Discussion
Hi guys! I have a question to do for u to enjoy...;) I have a problem with the ordering of null values in a query. When I have a table like this: <Number> <description> 1 "Desc1" 2 "Desc2" 2 "Desc3" 3 "Desc4" NULL "Desc5" 4 "Desc4" and then i do this query: "select * from Table order by Number desc"; this return a result set that has this order: NULL, 1, 2, 2, 3, 4. The problem here is that I need NULL at the end, like this: 1, 2, 2, 3, NULL. Do I make myself clear? Is there any setting in the server or the data base that i can change to do this? Do u know another solution? Many thanx in advantage. Jor. PS: Sorry about my english, i hope u understand all of this.
select * from t;
id name
0 KARL
1 JAMES
2 SIMON
3 MIKE
2 SIMON
2 SIMON
DAVID
MICHAEL
select * from t
order by id asc;
id name
DAVID
MICHAEL
0 KARL
1 JAMES
2 SIMON
2 SIMON
2 SIMON
3 MIKE
select * from t
order by *nvl(id, 1E99)* asc;
id name
0 KARL
1 JAMES
2 SIMON
2 SIMON
2 SIMON
3 MIKE
DAVID
MICHAEL
Ayyyhhh, Jorge... Jorge... Te dije que la solución estaba por NVL!!! ;) See you ;) Jorge wrote: > Hi guys! > I have a question to do for u to enjoy...;) > I have a problem with the ordering of null values in a query. When I > have a table like this: > > <Number> <description> > 1 "Desc1" > 2 "Desc2" > 2 "Desc3" > 3 "Desc4" > NULL "Desc5" > 4 "Desc4" > > and then i do this query: "select * from Table order by Number desc"; > this return a result set that has this order: NULL, 1, 2, 2, 3, 4. The > problem here is that I need NULL at the end, like this: 1, 2, 2, 3, > NULL. > Do I make myself clear? > Is there any setting in the server or the data base that i can change > to do this? Do u know another solution? > Many thanx in advantage. > Jor. > > PS: Sorry about my english, i hope u understand all of this.