I have a query that, in certain situations, does not return a value.
In this case I would like to get a value of 0, I tried to use ifnull
, but without success.
SELECT ifnull((valor * t1.PBRT),'0') AS C_MP
FROM engenharia_custo_mp t0
,(
SELECT MEDIDA1
,PBRT
FROM engenharia_produto
WHERE codigo = '0304502500701'
) t1
,(
SELECT MAT_PRIMAPK
FROM engenharia_materia_prima
WHERE DESCRICAO = (
SELECT MAT_PRIMAFK
FROM engenharia_produto
WHERE codigo = '0304502500701'
)
) t2
WHERE t1.MEDIDA1 = t0.ESPESSURA
AND t2.MAT_PRIMAPK = t0.MAT_PRIMAFK2