List:General Discussion« Previous MessageNext Message »
From:obed Date:July 25 2006 10:39pm
Subject:change a empty value for 0
View as plain text  
Hi all !

i have two tables  ingenio  and  detalle_tanque, detalle_tanque has a
foreign key to ingenio, i want to show all the ingenio values and a
sum of the cantidad field in the detalle_tanque table for each value
in ingenio, but one of the ingenio's values it doesn't exist in
detalle_tanque, i get this

mysql> select id_ingenio, (select case when sum(cantidad) is null then
0 else sum(cantidad) end from detalle_transaccion where
id_ingenio=ingenio.id_ingenio group by id_ingenio) as cantidad from
ingenio LIMIT 5;

+------------+----------+
| id_ingenio | cantidad |
+------------+----------+
|          1 |     NULL |
|          2 |     NULL |
|          3 |     NULL |
|          4 |  2622.77 |
|          5 |     NULL |
+------------+----------+
5 rows in set (0.01 sec)

i want to change de value of null to 0, but i don't know why i can't do it with

sum(cantidad) is null then 0 else sum(cantidad) end

thanks in advanced ...

any help it will be good for me ... !!!

-- 

http://www.obed.org.mx ---> blog
Thread
change a empty value for 0obed26 Jul
  • Re: change a empty value for 0Chris White26 Jul
  • Re: change a empty value for 0joao26 Jul
    • Re: change a empty value for 0obed26 Jul
  • Re: change a empty value for 0joao26 Jul
    • Re: change a empty value for 0obed26 Jul
RE: change a empty value for 0Quentin Bennett26 Jul