On 7/26/06, João Cândido de Souza Neto <[EMAIL PROTECTED]> wrote:
Hi.
Let me explain something about coalesce.
coalesce(field,0) return 0 if the field value equals null or the field value
if it´s not null.
:-) ooo !!! ok... it's the same to do: case when field is null then
0 else field end
Hi.
Let me explain something about coalesce.
coalesce(field,0) return 0 if the field value equals null or the field value
if it´s not null.
"obed" <[EMAIL PROTECTED]> escreveu na mensagem
news:[EMAIL PROTECTED]
> Hi. thanks ! but nop...
>
> SELECT id_ingenio,cantidad FROM detalle_transaccion
obed [mailto:[EMAIL PROTECTED]
Sent: Wednesday, 26 July 2006 11:12 a.m.
To: João Cândido de Souza Neto
Cc: mysql@lists.mysql.com
Subject: Re: change a empty value for 0
Hi. thanks ! but nop...
SELECT id_ingenio,cantidad FROM detalle_transaccion WHERE cantidad IS NULL;
Empty set (0.00 sec)
and
Hi. thanks ! but nop...
SELECT id_ingenio,cantidad FROM detalle_transaccion WHERE cantidad IS NULL;
Empty set (0.00 sec)
and with coalesce
nop :-( it's the same problem
mysql> select id_ingenio, (select case when sum(
coalesce(cantidad,NULL) ) is null then 0 else sum(cantidad) end f
Try this:
select id_ingenio, (select sum(coalesce(cantidad,0)) from
detalle_transaccion where
id_ingenio=ingenio.id_ingenio group by id_ingenio) as cantidad from
ingenio LIMIT 5;
"obed" <[EMAIL PROTECTED]> escreveu na mensagem
news:[EMAIL PROTECTED]
> Hi all !
>
> i have two tables ingenio a
> ++--+
>
> | id_ingenio | cantidad |
>
> ++--+
>
> | 1 | NULL |
> | 2 | NULL |
> | 3 | NULL |
> | 4 | 2622.77 |
> | 5 | NULL |
>
> ++--+
> 5 rows in set (0.01 sec)
You can use