I have the following query:
select ic14.cantidad_recepcionada as recepcionados
from comex_015 ic15
inner join comex_014 ic14 on ic15.invoice=ic14.invoice
where ic14.codigo_producto='KO555581012EA40' and ic14.invoice !='0'
group by ic14.pedido
order by ic14.pedido desc
limit 1
Which shows me the data ic14.cantidad_recepcionada
, given the conditions mentioned,
until there is everything right ..
But I need to add a new condition, which shows me the data ic14.cantidad_recepcionada
according to a record in the table comex_015
I need that when your registration in ic15.fecha_recepcion
is null , do not show me the data you are currently bringing or show it at zero.
I was trying this way, but the result it shows is a INT DE VALOR 1 , when it should show a decimal of (11,0) which is < strong> ic14.cantidad_recepcionada
which corresponds to 90 .
select ic14.cantidad_recepcionada =
(case when ic15.fecha_recepcion is not null then ic14.cantidad_recepcionada
when ic15.fecha_recepcion is null then 0
end) as recepcionado
from comex_015 ic15
inner join comex_014 ic14 on ic15.invoice=ic14.invoice
where ic14.codigo_producto='KO555581012EA40' and ic14.invoice !='0'
group by ic14.pedido
order by ic14.pedido desc
limit 1